Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata
Error rendering macro 'code': Invalid value specified for parameter 'lang'
*&---------------------------------------------------------------------*
*& REPORT ZMM0069 *
*&---------------------------------------------------------------------*
*& Module : MM |
*& Application : The program loads the Purchasing Inforecords |
*& |
*&---------------------------------------------------------------------*
REPORT ZMM0069 NO STANDARD PAGE HEADING
MESSAGE-ID Z0
LINE-SIZE 132
LINE-COUNT 65(2).
*----------------------------------------------------------------------*
* Internal Tables *
*----------------------------------------------------------------------*
*Internal table for the purchasing info records fields.
DATA: BEGIN OF I_INFORECORD OCCURS 0,
MATNR(18),
LIFNR(10),
UOM(3),
EKGRP(3),
PLANNED_TIME(3),
UNDER_TOL(3),
OVER_TOL(3),
QTY(10),
PRICE_CAT(5),
INCO(3),
DESIGNATION(28),
NETPR(13),
SCALE_QTY1(10),
SCALE_PR1(13),
SCALE_QTY2(10),
SCALE_PR2(13),
SCALE_QTY3(13),
SCALE_PR3(10),
SCALE_QTY4(13),
SCALE_PR4(10),
SCALE_QTY5(13),
SCALE_PR5(10),
SCALE_QTY6(13),
SCALE_PR6(10),
SCALE_QTY7(13),
SCALE_PR7(10),
SCALE_QTY8(13),
SCALE_PR8(10),
SCALE_QTY9(13),
SCALE_PR9(10),
SCALE_QTY10(13),
SCALE_PR10(10),
END OF I_INFORECORD.
** Internal table for Old and New Vendor number
DATA : BEGIN OF I_LFB1 OCCURS 1,
LIFNR(10),
ALTKN(10),
END OF I_LFB1.
** Declare internal table for Call Transaction and BDC Session
DATA: I_BDC_TABLE LIKE BDCDATA OCCURS 0 WITH HEADER LINE.
*----------------------------------------------------------------------*
* Global Variables *
*----------------------------------------------------------------------*
DATA: G_COUNTER(2) TYPE N,
G_FIELD_NAME(18) TYPE C,
ZC_YES TYPE SYFTYPE VALUE 'X'.
*----------------------------------------------------------------------*
* Selection Screen *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME TITLE TEXT-001.
PARAMETERS: P_FNAME1 TYPE LOCALFILE .
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK B WITH FRAME TITLE TEXT-002.
PARAMETERS: P_RLOC1 AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN BEGIN OF BLOCK C WITH FRAME TITLE TEXT-003.
PARAMETERS P_GROUP(12) OBLIGATORY DEFAULT 'ZPURCHINFO'.
SELECTION-SCREEN END OF BLOCK C.
SELECTION-SCREEN END OF BLOCK B.
SELECTION-SCREEN END OF BLOCK A.
**WRITE the report header
TOP-OF-PAGE.
* INCLUDE zheading.
*----------------------------------------------------------------------*
* Start of selection *
*----------------------------------------------------------------------*
START-OF-SELECTION.
* Load Input file
  PERFORM F_LOAD_INPUT_FILE.
* Create BDC records.
  PERFORM CREATE_BDC_RECORDS .
*&---------------------------------------------------------------------*
*& Form Create_BDC_records
*&---------------------------------------------------------------------*
* Perform the BDC for the records in the internal table
*----------------------------------------------------------------------*
FORM CREATE_BDC_RECORDS .
  IF NOT I_INFORECORD[] IS INITIAL.
** Open BDC session
    PERFORM OPEN_BDC_SESSION.
    SELECT LIFNR ALTKN FROM LFB1 INTO TABLE I_LFB1
    FOR ALL ENTRIES IN I_INFORECORD
    WHERE ALTKN = I_INFORECORD-LIFNR.
* Sorting the Internal table for better performance
    SORT I_LFB1 BY ALTKN.
    LOOP AT I_INFORECORD.
***Mapping Old Vendor number to the new Vendor number
      READ TABLE I_LFB1 WITH KEY ALTKN = I_INFORECORD-LIFNR BINARY
      SEARCH.
      IF SY-SUBRC EQ 0.
        I_INFORECORD-LIFNR = I_LFB1-LIFNR.
      ENDIF.
      CLEAR I_BDC_TABLE[].
      PERFORM INSERT_SCREEN_HEADER.
* call transaction 'ME11' using i_bdc_table
* mode 'A'.
* CLEAR i_bdc_table.
    ENDLOOP.
    CLEAR I_INFORECORD[].
    PERFORM CLOSE_BDC_SESSION.
** Release the BDC sessions created
    PERFORM RELEASE_BDC.
  ENDIF.
ENDFORM. " open_group
*&---------------------------------------------------------------------*
*& Form bdc_dynpro_start
*&---------------------------------------------------------------------*
* Start the screen for the transfer of fields
*----------------------------------------------------------------------*
FORM BDC_DYNPRO_START USING P_G_PROGRAM_1
P_G_SCREEN.
  CLEAR I_BDC_TABLE.
  I_BDC_TABLE-PROGRAM = P_G_PROGRAM_1.
  I_BDC_TABLE-DYNPRO = P_G_SCREEN.
  I_BDC_TABLE-DYNBEGIN = 'X'.
  APPEND I_BDC_TABLE.
ENDFORM. " bdc_dynpro_start_start
*&---------------------------------------------------------------------*
*& Form bdc_insert_field
*&---------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_INSERT_FIELD USING F_NAME F_VALUE.
  IF F_VALUE <> SPACE.
    CLEAR I_BDC_TABLE.
    I_BDC_TABLE-FNAM = F_NAME.
    I_BDC_TABLE-FVAL = F_VALUE.
    APPEND I_BDC_TABLE.
  ENDIF.
ENDFORM. "bdc_insert_field
*&--------------------------------------------------------------------*
*& Form open_bdc_session
*&--------------------------------------------------------------------*
* Open a BDC session
*---------------------------------------------------------------------*
FORM OPEN_BDC_SESSION .
** Open BDC session and create and update records
  CALL FUNCTION 'BDC_OPEN_GROUP'
  EXPORTING
  CLIENT = SY-MANDT
* DEST = FILLER8
  GROUP = P_GROUP
* HOLDDATE = FILLER8
  KEEP = 'X'
  USER = SY-UNAME
* RECORD = FILLER1
* PROG = SY-CPROG
* IMPORTING
* QID =
  EXCEPTIONS
  CLIENT_INVALID = 1
  DESTINATION_INVALID = 2
  GROUP_INVALID = 3
  GROUP_IS_LOCKED = 4
  HOLDDATE_INVALID = 5
  INTERNAL_ERROR = 6
  QUEUE_ERROR = 7
  RUNNING = 8
  SYSTEM_LOCK_ERROR = 9
  USER_INVALID = 10
  OTHERS = 11
  .
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM. " create_bdc_session
*&---------------------------------------------------------------------*
*& Form insert_screen_header
*&---------------------------------------------------------------------*
* Screen flow for the transfer of fields
*----------------------------------------------------------------------*
FORM INSERT_SCREEN_HEADER .
* First Screen 100
  PERFORM BDC_DYNPRO_START USING 'SAPMM06I' '0100'.
  PERFORM BDC_INSERT_FIELD USING:'BDC_CURSOR' 'EINA-LIFNR',
  'BDC_OKCODE' '/00',
  'EINA-LIFNR' I_INFORECORD-LIFNR,
  'EINA-MATNR' I_INFORECORD-MATNR,
  'EINE-EKORG' '1000',
  'RM06I-NORMB' ZC_YES.
****----------------------------------------*******
* Next Screen 101
  PERFORM BDC_DYNPRO_START USING 'SAPMM06I' '0101'.
  PERFORM BDC_INSERT_FIELD USING : 'BDC_CURSOR' 'EINA-MAHN1',
  'BDC_OKCODE' '/00',
  'EINA-MEINS' I_INFORECORD-UOM.
****----------------------------------------*******
*Next Screen 102
  PERFORM BDC_DYNPRO_START USING 'SAPMM06I' '0102'.
  PERFORM BDC_INSERT_FIELD USING : 'BDC_CURSOR' 'EINE-INCO2',
  'EINE-APLFZ' I_INFORECORD-PLANNED_TIME,
  'EINE-EKGRP' I_INFORECORD-EKGRP,
  'EINE-NORBM' I_INFORECORD-QTY.
  PERFORM BDC_INSERT USING 'EINE-UEBTK' ' '.
  PERFORM BDC_INSERT_FIELD USING:'EINE-PEINH' I_INFORECORD-SCALE_QTY1,
  'EINE-BPRME' I_INFORECORD-UOM,
  'EINE-UNTTO' '5',
  'EINE-UEBTO' '25',
  'EINE-MEPRF' I_INFORECORD-PRICE_CAT,
  'EINE-NETPR' I_INFORECORD-NETPR,
  'EINE-INCO1' I_INFORECORD-INCO,
  'EINE-INCO2' I_INFORECORD-DESIGNATION.
* Checking for Scale quantities
  IF I_INFORECORD-SCALE_QTY2 = SPACE.
    PERFORM BDC_INSERT_FIELD USING 'BDC_OKCODE' '=BU'.
    PERFORM INSERT_BDC_NEW.
  ELSE.
    PERFORM BDC_INSERT_FIELD USING 'BDC_OKCODE' '=KO'.
****----------------------------------------*******
* Next Screen 201
    PERFORM BDC_DYNPRO_START USING 'SAPMV13A' '0201'.
    PERFORM BDC_INSERT_FIELD USING : 'BDC_CURSOR' 'RV13A-DATAB',
    'BDC_OKCODE' '=PSTF'.
****----------------------------------------*******
* Next Screen 201
    PERFORM BDC_DYNPRO_START USING 'SAPMV13A' '0201'.
    PERFORM BDC_INSERT_FIELD USING : 'BDC_CURSOR' 'KONP-KSCHL(01)',
    'BDC_OKCODE' '=PSTF',
    'RV130-SELKZ(01)' ZC_YES.
****----------------------------------------*******
* LAST SCREEN 303
    PERFORM BDC_DYNPRO_START USING 'SAPMV13A' '0303'.
    PERFORM BDC_INSERT_FIELD USING : 'BDC_CURSOR' 'KONM-KBETR(03)',
    'BDC_OKCODE' '=SICH'.
* Counter to Loop the Item level entry
    G_COUNTER = 0.
    PERFORM SCALE_ENTRY USING I_INFORECORD-SCALE_QTY2
    I_INFORECORD-SCALE_PR2.
    PERFORM SCALE_ENTRY USING I_INFORECORD-SCALE_QTY3
    I_INFORECORD-SCALE_PR3.
    PERFORM SCALE_ENTRY USING I_INFORECORD-SCALE_QTY4
    I_INFORECORD-SCALE_PR4.
    PERFORM SCALE_ENTRY USING I_INFORECORD-SCALE_QTY5
    I_INFORECORD-SCALE_PR5.
    PERFORM SCALE_ENTRY USING I_INFORECORD-SCALE_QTY6
    I_INFORECORD-SCALE_PR6.
    PERFORM SCALE_ENTRY USING I_INFORECORD-SCALE_QTY7
    I_INFORECORD-SCALE_PR7.
    PERFORM SCALE_ENTRY USING I_INFORECORD-SCALE_QTY8
    I_INFORECORD-SCALE_PR8.
    PERFORM SCALE_ENTRY USING I_INFORECORD-SCALE_QTY9
    I_INFORECORD-SCALE_PR9.
    PERFORM SCALE_ENTRY USING I_INFORECORD-SCALE_QTY10
    I_INFORECORD-SCALE_PR10.
    PERFORM INSERT_BDC_NEW.
  ENDIF.
ENDFORM. " insert_screen_header
*&---------------------------------------------------------------------*
*& Form insert_bdc
*&---------------------------------------------------------------------*
* Insert BDC
*----------------------------------------------------------------------*
FORM INSERT_BDC_NEW .
  CALL FUNCTION 'BDC_INSERT'
  EXPORTING
  TCODE = 'ME11'
* POST_LOCAL = NOVBLOCAL
* PRINTING = NOPRINT
* SIMUBATCH = ' '
* CTUPARAMS = ' '
  TABLES
  DYNPROTAB = I_BDC_TABLE
  EXCEPTIONS
  INTERNAL_ERROR = 1
  NOT_OPEN = 2
  QUEUE_ERROR = 3
  TCODE_INVALID = 4
  PRINTING_INVALID = 5
  POSTING_INVALID = 6
  OTHERS = 7
  .
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  CLEAR I_BDC_TABLE[].
ENDFORM. " insert_bdc
*&---------------------------------------------------------------------*
*& Form close_bdc_session
*&---------------------------------------------------------------------*
* Close the BDC session
*----------------------------------------------------------------------*
FORM CLOSE_BDC_SESSION .
  CALL FUNCTION 'BDC_CLOSE_GROUP'
    EXCEPTIONS
      NOT_OPEN    = 1
      QUEUE_ERROR = 2
      OTHERS      = 3.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM. " close_bdc_session
*&---------------------------------------------------------------------*
*& Form f_load_input_file
*&---------------------------------------------------------------------*
* Upload the file
*----------------------------------------------------------------------*
FORM F_LOAD_INPUT_FILE.
* Check always Local file for upload
  IF P_RLOC1 = ZC_YES.
    CALL FUNCTION 'WS_UPLOAD'
      EXPORTING
        FILENAME                = P_FNAME1
        FILETYPE                = 'DAT'
      TABLES
        DATA_TAB                = I_INFORECORD
      EXCEPTIONS
        CONVERSION_ERROR        = 1
        FILE_OPEN_ERROR         = 2
        FILE_READ_ERROR         = 3
        INVALID_TYPE            = 4
        NO_BATCH                = 5
        UNKNOWN_ERROR           = 6
        INVALID_TABLE_WIDTH     = 7
        GUI_REFUSE_FILETRANSFER = 8
        CUSTOMER_ERROR          = 9
        OTHERS                  = 10.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
      WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      STOP.
    ENDIF.
  ENDIF.
*
ENDFORM. " f_load_input_file
*&---------------------------------------------------------------------*
*& Form release_bdc
*&---------------------------------------------------------------------*
* Release the session
*----------------------------------------------------------------------*
FORM RELEASE_BDC.
  SUBMIT RSBDCSUB WITH MAPPE EQ P_GROUP
  WITH VON EQ SY-DATUM
  WITH BIS EQ SY-DATUM
  WITH FEHLER EQ '.'
  EXPORTING LIST TO MEMORY
  AND RETURN.
ENDFORM. " release_bdc
*&---------------------------------------------------------------------*
*& Form scale_entry
*&---------------------------------------------------------------------*
* Populate the Scale quantities
*----------------------------------------------------------------------*
* -->P_SCALE_QTY
* -->P_SCALE_PRICE
*----------------------------------------------------------------------*
FORM SCALE_ENTRY USING P_SCALE_QTY
P_SCALE_PRICE.
* Increment the Counter
  G_COUNTER = G_COUNTER + 1.
  IF P_SCALE_QTY <> SPACE.
    CONCATENATE 'KONM-KSTBM(' G_COUNTER ')' INTO G_FIELD_NAME.
    PERFORM BDC_INSERT_FIELD USING G_FIELD_NAME P_SCALE_QTY.
    CONCATENATE 'KONM-KBETR(' G_COUNTER ')' INTO G_FIELD_NAME.
    PERFORM BDC_INSERT_FIELD USING G_FIELD_NAME P_SCALE_PRICE.
  ENDIF.
ENDFORM.                    "scale_entry
*&---------------------------------------------------------------------*
*& Form bdc_insert
*&---------------------------------------------------------------------*
* To uncheck the Unlimited (UEBTK)
*----------------------------------------------------------------------*
FORM BDC_INSERT USING F_NAME F_VALUE.
  CLEAR I_BDC_TABLE.
  I_BDC_TABLE-FNAM = F_NAME.
  I_BDC_TABLE-FVAL = F_VALUE.
  APPEND I_BDC_TABLE.
ENDFORM. " bdc_insert
*Selection texts
*----------------------------------------------------------
* P_FNAME1         Filename
* P_GROUP         Purchasing Group
* P_RLOC1         Reciveing Location
--------------------------------------------------------------------------------

 

 

  • No labels