Example BDC Program Of BOM In
Retail
Program of creating bom in sap in retail 6.4 c :>>>>>>>>> report ZCPBP_BOM_VER2 no standard page heading line-size 255. *include bdcrecx1. *parameters: dataset(132) lower case. *** DO NOT CHANGE - the generated data section - DO NOT CHANGE *** * * If it is nessesary to change the data section use the rules: * 1.) Each definition of a field exists of two lines * 2.) The first line shows exactly the comment * '* data element: ' followed with the data element * which describes the field. * If you don't have a data element use the * comment without a data element name * 3.) The second line shows the fieldname of the * structure, the fieldname must consist of * a fieldname and optional the character '_' and * three numbers and the field length in brackets * 4.) Each field must be type C. * *** Generated data section with specific formatting - DO NOT CHANGE *** data: begin of record OCCURS 0, * data element: MATNR MATNR(018), * data element: WERKS_D WERKS(004), * data element: STLAN STLAN(001), * data element: STALT STLAL(002), * data element: BASMN BMENG(017), * data element: POSTP POSTP(001), * data element: IDNRK IDNRK(018), * data element: KMPMG MENGE(018), end of record. DATA : V_PREV_MATNR(018), V_PREV_WERKS(004), V_PREV_STLAN(001), V_PREV_STLAL(001), V_COUNT(4) TYPE C, V_COUNT_NEXT(4) TYPE C, V_STRING TYPE STRING. DATA: I_BDCDATA TYPE STANDARD TABLE OF BDCDATA. DATA : W_BDCDATA TYPE BDCDATA. DATA : V_FILE_NAME TYPE RLGRAP-FILENAME, V_RECORD_INDEX TYPE SY-TABIX, V_RECORD_NEXT TYPE SY-TABIX, IS_SAME TYPE C, C_SPACE TYPE C VALUE space."'' '. *** End generated data section *** PARAMETER P_FILE LIKE RLGRAP-FILENAME MEMORY ID XYZ. AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE. PERFORM GET_FILE_NAME. start-of-selection. PERFORM READ_FLAT_FILE. PERFORM OPEN_BDC_GROUP. LOOP AT RECORD. V_COUNT = 1. V_COUNT_NEXT = V_COUNT + 1. IF V_PREV_MATNR = RECORD-MATNR AND V_PREV_WERKS = RECORD-WERKS AND V_PREV_STLAN = RECORD-STLAN AND V_PREV_STLAL = RECORD-STLAL . CONTINUE. ENDIF. CLEAR W_BDCDATA. REFRESH I_BDCDATA. V_RECORD_INDEX = SY-TABIX. V_RECORD_NEXT = V_RECORD_INDEX + 1. V_PREV_MATNR = RECORD-MATNR. V_PREV_WERKS = RECORD-WERKS. V_PREV_STLAN = RECORD-STLAN. V_PREV_STLAL = RECORD-STLAL. perform bdc_dynpro using 'SAPLCSDI' '0100'. perform bdc_field using 'BDC_CURSOR' 'RC29N-STLAL'. perform bdc_field using 'BDC_OKCODE' '/00'. perform bdc_field using 'RC29N-MATNR' record-MATNR. perform bdc_field using 'RC29N-WERKS' record-WERKS. perform bdc_field using 'RC29N-STLAN' record-STLAN. perform bdc_field using 'RC29N-STLAL' record-STLAL. perform bdc_dynpro using 'SAPLCSDI' '0110'. perform bdc_field using 'BDC_CURSOR' 'RC29K-BMENG'. perform bdc_field using 'BDC_OKCODE' '/00'. perform bdc_field using 'RC29K-BMENG' record-BMENG. perform bdc_dynpro using 'SAPLCSDI' '0111'. perform bdc_field using 'BDC_CURSOR' 'RC29K-LABOR'. perform bdc_field using 'BDC_OKCODE' '/00'. perform bdc_dynpro using 'SAPLCSDI' '0140'. CONCATENATE 'RC29P-POSTP(' V_COUNT ')' INTO V_STRING. *REPLACE ALL OCCURRENCES OF C_SPACE IN V_STRING WITH ''. CONDENSE V_STRING NO-GAPS. perform bdc_field using 'BDC_CURSOR' V_STRING. perform bdc_field using 'BDC_OKCODE' '/00'. CONCATENATE 'RC29P-IDNRK(' V_COUNT ')' INTO V_STRING. CONDENSE V_STRING NO-GAPS. perform bdc_field using V_STRING record-IDNRK. CONCATENATE 'RC29P-MENGE(' V_COUNT ')' INTO V_STRING. CONDENSE V_STRING NO-GAPS. perform bdc_field using V_STRING record-MENGE. CONCATENATE 'RC29P-POSTP(' V_COUNT ')' INTO V_STRING. CONDENSE V_STRING NO-GAPS. perform bdc_field using V_STRING record-POSTP. perform bdc_dynpro using 'SAPLCSDI' '0130'. perform bdc_field using 'BDC_OKCODE' '/00'. perform bdc_field using 'BDC_CURSOR' 'RC29P-POSNR'. perform bdc_field using 'RC29P-IDNRK' record-IDNRK. perform bdc_field using 'RC29P-MENGE' record-MENGE. perform bdc_dynpro using 'SAPLCSDI' '0131'. perform bdc_field using 'BDC_OKCODE' '/00'. perform bdc_field using 'BDC_CURSOR' 'RC29P-POTX1'. READ TABLE RECORD INDEX V_RECORD_NEXT. IF SY-SUBRC = 0 AND RECORD-MATNR = V_PREV_MATNR AND RECORD-WERKS = V_PREV_WERKS AND RECORD-STLAN = V_PREV_STLAN AND RECORD-STLAL = V_PREV_STLAL. IS_SAME = 'X'. ELSE. IS_SAME = ' '. ENDIF. WHILE IS_SAME = 'X'. CONCATENATE 'RC29P-POSTP(' V_COUNT_NEXT ')' INTO V_STRING. CONDENSE V_STRING NO-GAPS. perform bdc_dynpro using 'SAPLCSDI' '0140'. perform bdc_field using 'BDC_CURSOR' V_STRING. perform bdc_field using 'BDC_OKCODE' *** '/00'. 'FCNP'. CONCATENATE 'RC29P-IDNRK(' V_COUNT_NEXT ')' INTO V_STRING. CONDENSE V_STRING NO-GAPS. perform bdc_field using V_STRING record-IDNRK. CONCATENATE 'RC29P-MENGE(' V_COUNT_NEXT ')' INTO V_STRING. CONDENSE V_STRING NO-GAPS. perform bdc_field using V_STRING record-MENGE. CONCATENATE 'RC29P-POSTP(' V_COUNT_NEXT ')' INTO V_STRING. CONDENSE V_STRING NO-GAPS. perform bdc_field using V_STRING record-POSTP. perform bdc_dynpro using 'SAPLCSDI' '0130'. perform bdc_field using 'BDC_OKCODE' '/00'. perform bdc_field using 'BDC_CURSOR' 'RC29P-POSNR'. perform bdc_field using 'RC29P-IDNRK' record-IDNRK. perform bdc_field using 'RC29P-MENGE' record-MENGE. perform bdc_dynpro using 'SAPLCSDI' '0131'. perform bdc_field using 'BDC_OKCODE' '/00'. perform bdc_field using 'BDC_CURSOR' 'RC29P-POTX1'. V_PREV_MATNR = RECORD-MATNR. V_PREV_WERKS = RECORD-WERKS. V_PREV_STLAN = RECORD-STLAN. V_PREV_STLAL = RECORD-STLAL. V_RECORD_NEXT = V_RECORD_NEXT + 1. READ TABLE RECORD INDEX V_RECORD_NEXT. IF SY-SUBRC = 0 AND RECORD-MATNR = V_PREV_MATNR AND RECORD-WERKS = V_PREV_WERKS AND RECORD-STLAN = V_PREV_STLAN AND RECORD-STLAL = V_PREV_STLAL. IS_SAME = 'X'. ***V_COUNT_NEXT = V_COUNT_NEXT + 1. V_COUNT_NEXT = 2. ELSE. IS_SAME = ' '. ENDIF. ENDWHILE. perform bdc_dynpro using 'SAPLCSDI' '0140'. perform bdc_field using 'BDC_CURSOR' 'RC29P-POSNR(01)'. perform bdc_field using 'BDC_OKCODE' '=FCBU'. PERFORM BDC_INSERT. endLOOP. PERFORM BDC_CLOSE_GROUP. *&---------------------------------------------------------------------* *& Form READ_FLAT_FILE *&---------------------------------------------------------------------* * Read the Flat File Contents. *----------------------------------------------------------------------* FORM READ_FLAT_FILE . DATA : L_TMP_FILE TYPE STRING. L_TMP_FILE = P_FILE. CALL FUNCTION 'GUI_UPLOAD' EXPORTING FILENAME = L_TMP_FILE FILETYPE = 'ASC' HAS_FIELD_SEPARATOR = 'X' TABLES DATA_TAB = RECORD EXCEPTIONS FILE_OPEN_ERROR = 1 FILE_READ_ERROR = 2 NO_BATCH = 3 GUI_REFUSE_FILETRANSFER = 4 INVALID_TYPE = 5 NO_AUTHORITY = 6 UNKNOWN_ERROR = 7 BAD_DATA_FORMAT = 8 HEADER_NOT_ALLOWED = 9 SEPARATOR_NOT_ALLOWED = 10 HEADER_TOO_LONG = 11 UNKNOWN_DP_ERROR = 12 ACCESS_DENIED = 13 DP_OUT_OF_MEMORY = 14 DISK_FULL = 15 DP_TIMEOUT = 16 OTHERS = 17 . 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. " READ_FLAT_FILE *----------------------------------------------------------------------* * Start new screen * *----------------------------------------------------------------------* FORM BDC_DYNPRO USING PROGRAM DYNPRO. CLEAR W_BDCDATA. W_BDCDATA-PROGRAM = PROGRAM. W_BDCDATA-DYNPRO = DYNPRO. W_BDCDATA-DYNBEGIN = 'X'. APPEND W_BDCDATA TO I_BDCDATA. CLEAR W_BDCDATA. ENDFORM. *----------------------------------------------------------------------* * Insert field * *----------------------------------------------------------------------* FORM BDC_FIELD USING FNAM FVAL. CLEAR W_BDCDATA. W_BDCDATA-FNAM = FNAM. W_BDCDATA-FVAL = FVAL. APPEND W_BDCDATA TO I_BDCDATA. ENDFORM. *&---------------------------------------------------------------------* *& Form GET_FILE_NAME *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM GET_FILE_NAME . CALL FUNCTION 'KD_GET_FILENAME_ON_F4' * EXPORTING * PROGRAM_NAME = SYST-REPID * DYNPRO_NUMBER = SYST-DYNNR * FIELD_NAME = ' ' * STATIC = ' ' * MASK = ' ' CHANGING FILE_NAME = V_FILE_NAME EXCEPTIONS MASK_TOO_LONG = 1 OTHERS = 2 . IF SY-SUBRC <> 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. P_FILE = V_FILE_NAME. ENDFORM. " GET_FILE_NAME *&---------------------------------------------------------------------* *& Form OPEN_BDC_GROUP *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM OPEN_BDC_GROUP . CALL FUNCTION 'BDC_OPEN_GROUP' EXPORTING CLIENT = SY-MANDT * DEST = FILLER8 GROUP = 'ZCS01' * HOLDDATE = FILLER8 KEEP = 'X' USER = SY-UNAME * RECORD = FILLER1 * PROG = SY-CPROG * DCPFM = '%' * DATFM = '%' * 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. " OPEN_BDC_GROUP *&---------------------------------------------------------------------* *& Form BDC_INSERT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM BDC_INSERT . CALL FUNCTION 'BDC_INSERT' EXPORTING TCODE = 'CS01' * POST_LOCAL = NOVBLOCAL * PRINTING = NOPRINT * SIMUBATCH = ' ' * CTUPARAMS = ' ' TABLES DYNPROTAB = I_BDCDATA 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. ENDFORM. " BDC_INSERT *&---------------------------------------------------------------------* *& Form BDC_CLOSE_GROUP *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM BDC_CLOSE_GROUP . 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. MESSAGE 'Execute Session ZCS01 From SM35' type 'I'. ENDFORM. " BDC_CLOSE_GROUPTips by : Varun Walia
More Abapers Questions: ABAP Books ListABAP/4 Certification, Programming and Object Oriented Programming Books ABAP Menu:
Return to Index:-
(c) www.gotothings.com All material on this site is Copyright.
|