Go on link..

link us with ...

Monday, January 3, 2011

BDC with TCODE f-02

Please refer the program RFBISA00. And also attaching a sample code for that.
REPORT Zf02 MESSAGE-ID Z1.
TABLES: T001, "Company Codes SKB1, "GL Account Master (Company Code)
AUFK, "Order Master data BKPF, "Document Header Table
ZMETA, "Meta Table used for messaging
TCURC, "Currency Check Table TGSB, "Check table for business area
T100. "Message Table ************************************************************************ *
Input table to load Interface File
DATA: BEGIN OF INFILE OCCURS 0,
REC_TYPE(01) TYPE C,
POST_KEY(02) TYPE C,
FILL_01(08) TYPE C, ACCNT(10) TYPE C, FILL_02(04) TYPE C, AMOUNT(16) TYPE C, BUSINESS_AREA(03) TYPE C, FILL_03(06) TYPE C, SPECIAL_GL(01) TYPE C, FILL_04(05) TYPE C, ORDER(10) TYPE C, FILL_05(25) TYPE C, TEXT(50) TYPE C, FILL_07(65) TYPE C, DUE_ON_DATE(8) TYPE C, DOLLAR_AMT TYPE P DECIMALS 2, SORT_FIELD(13) TYPE C, FILL_06(05) TYPE C, END OF INFILE. DATA: BEGIN OF BA_CNT_TAB OCCURS 5, BUSINESS_AREA(04) TYPE C, REC_CNT TYPE I, DOLLAR_AMT TYPE P DECIMALS 2, DEBIT_ACCUM TYPE P DECIMALS 2, CREDIT_ACCUM TYPE P DECIMALS 2, END OF BA_CNT_TAB. DATA: BEGIN OF BDC_TAB OCCURS 100. INCLUDE STRUCTURE BDCDATA. DATA: END OF BDC_TAB. DATA: BEGIN OF HEADER, REC_TYPE(01) TYPE C, DOC_MDY(10) TYPE C, POST_MDY(10) TYPE C, DOC_TYPE(02) TYPE C, FILL03(18) TYPE C, COMPANY_CODE(04) TYPE C, FILL04(05) TYPE C, PERIOD(02) TYPE C, FILL05(04) TYPE C, CURRENCY(05) TYPE C, FILL06(10) TYPE C, REFERENCE_DOC(16) TYPE C, FILL09(04) TYPE C, TEXT(25) TYPE C, FILL07(25) TYPE C, END OF HEADER. DATA: BEGIN OF IN_TRAILER, RECORD_TYPE(01) TYPE C, INTERFACE_ID(04) TYPE C, FILL_02(06) TYPE C, REC_CNT(06) TYPE N, FILL_03(04) TYPE C, TOT_AMOUNT(20) TYPE N, DR_CR_IND(01) TYPE C, DATE(08) TYPE C, TIME(06) TYPE C, FILE_NAME(15) TYPE C, END OF IN_TRAILER. DATA: BEGIN OF GROUP_NAME, FILLER(01) TYPE C VALUE 'Z', INF_ID(04) TYPE C VALUE 'AR01', "Interface Id INF_NAME(07) TYPE C VALUE 'GEN_AR ', END OF GROUP_NAME. DATA: EXECUTION(15) TYPE C VALUE 'DEAMON', BEGIN(01) TYPE C VALUE 'X', WORK_DOC_DATE(08) TYPE C, FILE(45) TYPE C, PREV_PK(02) TYPE C, PREV_BUSINESS_AREA LIKE INFILE-BUSINESS_AREA, PREV_AMOUNT LIKE INFILE-AMOUNT, PREV_DOLLAR_AMT LIKE INFILE-DOLLAR_AMT, PREV_ORDER LIKE INFILE-ORDER, PREV_TEXT LIKE INFILE-TEXT, PREV_DUE_ON_DATE LIKE INFILE-DUE_ON_DATE, POSTING_KEY(02) TYPE C, FIRST_TIME(05) TYPE C VALUE 'TRUE ', NEW_BDC(05) TYPE C VALUE 'TRUE ', ABEND_JOB(05) TYPE C VALUE 'FALSE', BDC_OPENNED(05) TYPE C VALUE 'FALSE', TRAILER_PRESENT(05) TYPE C VALUE 'FALSE', BDC_TAB_CREATED(05) TYPE C VALUE 'FALSE', BAD_FILE(05) TYPE C VALUE 'FALSE', EOJ(05) TYPE C VALUE 'FALSE', CHAR_DATA(16) TYPE C, DISPLAY_DEBIT(16) TYPE C, DISPLAY_CREDIT(16) TYPE C, FULL_FIL_NAME(40) TYPE C, NUMERIC_10(10) TYPE N, CHAR_12(12) TYPE C, NUMERIC_12(12) TYPE N, NUMERIC_2(02) TYPE N, BDC_TRANS_CNT TYPE I, TOTAL_RECS TYPE I, DETAIL_REC_CNT TYPE I, PHANTOM_ACCUM TYPE P DECIMALS 2, AMT_DEBIT_ADDED TYPE P DECIMALS 2, NUM_DATA TYPE P DECIMALS 2, AMT_CREDIT_ADDED TYPE P DECIMALS 2, TOT_AMOUNT TYPE P DECIMALS 2, TOT_DEBIT TYPE P DECIMALS 2, TOT_CREDIT TYPE P DECIMALS 2. DATA NO_BA_FLG(1) TYPE C. CONSTANTS: DEFAULT_FILENAME(15) TYPE C VALUE 'ar_upload ', HEADER_REC(01) TYPE C VALUE 'H', DETAIL_REC(01) TYPE C VALUE 'D', TRAILER_REC(01) TYPE C VALUE 'T', POST(03) TYPE C VALUE '/11', PHANTOM_ACCNT(10) TYPE C VALUE '199997', DEBIT_PK01(02) TYPE C VALUE '01', DEBIT_PK09(02) TYPE C VALUE '09', DEBIT_PK40(02) TYPE C VALUE '40', CREDIT_PK19(02) TYPE C VALUE '19', CREDIT_PK50(02) TYPE C VALUE '50', CREDIT_PK11(02) TYPE C VALUE '11', NUMERIC_DATA(10) TYPE C VALUE '0123456789', NUMERIC_DATA_SPACE(11) TYPE C VALUE ' 0123456789', TRANS_CODE(20) TYPE C VALUE 'F-02', COMMA_DATA(01) TYPE C VALUE ','. INCLUDE ZI000001. ************************************************************************ * PARAMETERS ************************************************************************ PARAMETERS: FIL_NAME(15) DEFAULT 'ar_upload' LOWER CASE, FIL_PATH(40) DEFAULT '/data/work/' LOWER CASE, *To submit the bdc session for automatic processing submit AS CHECKBOX DEFAULT 'X'. ************************************************************************ *----------------------------------------------------------------------- * Main Program *----------------------------------------------------------------------- ************************************************************************ * Entry point for manual execution *----------------------------------------------------------------------- EXECUTION = 'ONLINE'. PERFORM MAINLINE_ROUTINE USING FIL_NAME FIL_PATH ABEND_JOB. *----------------------------------------------------------------------- * Entry point for execution by DEAMON *----------------------------------------------------------------------- FORM MAINLINE_ROUTINE USING FILENAME PATH ABORT. MOVE FILENAME TO FULL_FIL_NAME. PERFORM PROCESS_INPUT_FILE USING FILENAME PATH. IF ABEND_JOB = FALSE. PERFORM PREPARE_DATA. IF BAD_FILE = FALSE. PERFORM PROCESS_TRAILER. ENDIF. ENDIF. * This creates the BDC. IF ABEND_JOB = FALSE. PERFORM PROCESS_INFILE. ENDIF. PERFORM EOJ_ROUTINE. MOVE: ABEND_JOB TO ABORT. ENDFORM. *----------------------------------------------------------------------* *** END OF MAIN ROUTINE *----------------------------------------------------------------------* FORM PROCESS_INPUT_FILE USING FILENAME PATH. CONCATENATE PATH FILENAME INTO FILE. TRANSLATE FILE TO LOWER CASE. MOVE: DEFAULT_FILENAME TO IN_TRAILER-FILE_NAME. OPEN DATASET FILE FOR INPUT IN TEXT MODE. IF SY-SUBRC NE 0. MOVE: TRUE TO ABEND_JOB. ELSE. DO. READ DATASET FILE INTO INFILE. IF SY-SUBRC NE 0. TOTAL_RECS = SY-INDEX - 3. EXIT. ENDIF. APPEND INFILE. ENDDO. CLOSE DATASET FILE. ENDIF. ENDFORM. ************************************************************************ * Load input data to work table(s) FORM PREPARE_DATA. SORT INFILE BY REC_TYPE DESCENDING BUSINESS_AREA. SY-SUBRC = 0. LOOP AT INFILE. IF SY-SUBRC NE 0. EXIT. ENDIF. CASE INFILE-REC_TYPE. "Use field that is to be used to "determine type of record WHEN HEADER_REC. MOVE: INFILE TO HEADER. DELETE INFILE INDEX SY-TABIX. WHEN DETAIL_REC. IF INFILE-AMOUNT CA COMMA_DATA. MOVE TRUE TO ABEND_JOB. ELSE. IF INFILE-POST_KEY = DEBIT_PK01 OR INFILE-POST_KEY = DEBIT_PK09 OR INFILE-POST_KEY = DEBIT_PK40. INFILE-DOLLAR_AMT = INFILE-AMOUNT. ELSEIF INFILE-POST_KEY = CREDIT_PK19 OR INFILE-POST_KEY = CREDIT_PK11 OR INFILE-POST_KEY = CREDIT_PK50. INFILE-DOLLAR_AMT = INFILE-AMOUNT * -1. ELSE. MOVE: TRUE TO ABEND_JOB, TRUE TO BAD_FILE. ENDIF. MODIFY INFILE INDEX SY-TABIX. ENDIF. WHEN TRAILER_REC. MOVE: INFILE TO IN_TRAILER, TRUE TO TRAILER_PRESENT. DELETE INFILE INDEX SY-TABIX. * PERFORM CHECK_DATE_CONTROL_FILE. IF ABEND_JOB = TRUE. EXIT. ENDIF. WHEN OTHERS. ENDCASE. ENDLOOP. ENDFORM. * PROCESS TRAILER RECORD *----------------------------------------------------------------------- FORM PROCESS_TRAILER. *----------------------------------------------------------------------- IF TOTAL_RECS = 0. MOVE: TRUE TO ABEND_JOB. EXIT. ELSEIF TRAILER_PRESENT = FALSE. MOVE: TRUE TO ABEND_JOB. EXIT. ENDIF. ENDFORM. *---------------------------------------------------------------------* * FORM PROCESS_INFILE * *---------------------------------------------------------------------* * ........ * *---------------------------------------------------------------------* FORM PROCESS_INFILE. *----------------------------------------------------------------------- * This routine loops through the Infile Table created from the input * file and creates the appropriate BDC transactions necessary to * input the data into SAP *----------------------------------------------------------------------- MOVE: 0 TO SY-SUBRC. SORT INFILE BY BUSINESS_AREA AMOUNT POST_KEY. LOOP AT INFILE. PERFORM CREATE_BDC. ENDLOOP. * Handle the last break occurring because at end of file IF ABEND_JOB = FALSE. MOVE: TRUE TO EOJ. PERFORM FORMAT_SCRN_0300_LAST. PERFORM INSERT_BDCDATA. ENDIF. ENDFORM. ************************************************************************ * Create BDC FORM CREATE_BDC. *----------------------------------------------------------------------- * Include logic applicable to Interface that is necessary to format * the necessary BDC screens. *----------------------------------------------------------------------- SY-SUBRC = 0. IF NEW_BDC EQ TRUE. PERFORM OPEN_BDC. IF ABEND_JOB = TRUE. EXIT. ENDIF. ENDIF. IF FIRST_TIME = TRUE. CLEAR BA_CNT_TAB. PERFORM FORMAT_SCRN_0100. PERFORM FORMAT_BREAK_FIELDS. ELSEIF INFILE-BUSINESS_AREA NE PREV_BUSINESS_AREA OR DETAIL_REC_CNT = 49. PERFORM FORMAT_SCRN_0300_LAST. PERFORM INSERT_BDCDATA. IF ABEND_JOB = FALSE. MOVE: TRUE TO BDC_TAB_CREATED. PERFORM FORMAT_SCRN_0100. PERFORM FORMAT_BREAK_FIELDS. ENDIF. ELSE. PERFORM FORMAT_SCRN_0300_DETAIL. PERFORM FORMAT_BREAK_FIELDS. ENDIF. IF ABEND_JOB = FALSE. IF FIRST_TIME = TRUE. MOVE: TRUE TO BDC_TAB_CREATED, FALSE TO FIRST_TIME. ENDIF. ELSE. EXIT. ENDIF. ENDFORM. ************************************************************************ * Format Break Fields FORM FORMAT_BREAK_FIELDS. *----------------------------------------------------------------------- * This form format fields necessary for breaking logic and postions * the BA_CNT_TAB at the Business Area being processed. MOVE: INFILE-BUSINESS_AREA TO PREV_BUSINESS_AREA, INFILE-POST_KEY TO PREV_PK, INFILE-AMOUNT TO PREV_AMOUNT, INFILE-DOLLAR_AMT TO PREV_DOLLAR_AMT, INFILE-ORDER TO PREV_ORDER, INFILE-TEXT TO PREV_TEXT, INFILE-DUE_ON_DATE TO PREV_DUE_ON_DATE. ENDFORM. ************************************************************************ * format screen 0100 FORM FORMAT_SCRN_0100. *----------------------------------------------------------------------- * This form contains the logic to create screen 0100 SY-SUBRC = 0. IF BA_CNT_TAB-BUSINESS_AREA NE INFILE-BUSINESS_AREA. * Position BA_CNT_TAB at business area currently processing. LOOP AT BA_CNT_TAB. IF BA_CNT_TAB-BUSINESS_AREA = INFILE-BUSINESS_AREA. EXIT. ENDIF. ENDLOOP. ENDIF. PERFORM DYNPRO_SAPMF05A_0100 USING INFILE-POST_KEY INFILE-ACCNT. ENDFORM. ************************************************************************ * FORMAT SCREEN 0300 FOR LAST DETAIL FORM FORMAT_SCRN_0300_LAST. *----------------------------------------------------------------------- * This form formats the last detail screen 0300 and a phantom entry * if needed. Screen 0002 is also formatted for each 0300. ADD: PREV_DOLLAR_AMT TO PHANTOM_ACCUM, 1 TO DETAIL_REC_CNT. IF PREV_DOLLAR_AMT GT 0. ADD: PREV_DOLLAR_AMT TO AMT_DEBIT_ADDED. ELSE. ADD: PREV_DOLLAR_AMT TO AMT_CREDIT_ADDED. ENDIF. IF DETAIL_REC_CNT LT BA_CNT_TAB-REC_CNT. IF PHANTOM_ACCUM LT 0. * Reverse posting key since being posted as an offset to the accumulated * Amount. MOVE DEBIT_PK40 TO POSTING_KEY. NUM_DATA = PHANTOM_ACCUM * -1. ELSE. MOVE CREDIT_PK50 TO POSTING_KEY. NUM_DATA = PHANTOM_ACCUM. ENDIF. PERFORM DYNPRO_SAPMF05A_0300 USING PREV_AMOUNT PREV_TEXT PREV_DUE_ON_DATE POSTING_KEY PHANTOM_ACCNT ' '. IF PREV_PK = '40' OR PREV_PK = '50'. PERFORM DYNPRO_SAPLKACB_0002 USING PREV_BUSINESS_AREA PREV_ORDER. ENDIF. MOVE: NUM_DATA TO CHAR_DATA, POSTING_KEY TO PREV_PK. PERFORM DYNPRO_SAPMF05A_0300 USING CHAR_DATA '' '' '' '' ''. PERFORM BDC_VALUE USING 'BDC_OKCODE' POST. PERFORM DYNPRO_SAPLKACB_0002 USING PREV_BUSINESS_AREA ' '. ELSE. PERFORM DYNPRO_SAPMF05A_0300 USING PREV_AMOUNT PREV_TEXT PREV_DUE_ON_DATE '' '' ''. PERFORM BDC_VALUE USING 'BDC_OKCODE' POST. IF PREV_PK = '40' OR PREV_PK = '50'. PERFORM DYNPRO_SAPLKACB_0002 USING PREV_BUSINESS_AREA PREV_ORDER. ENDIF. ENDIF. CLEAR: DETAIL_REC_CNT, PHANTOM_ACCUM. ENDFORM. ************************************************************************ * FORMAT DETAIL FOR SCREEN 0300 FORM FORMAT_SCRN_0300_DETAIL. *----------------------------------------------------------------------- * This FORM formats screen 0300 for a detail record along with its * screen 0002 ADD: PREV_DOLLAR_AMT TO PHANTOM_ACCUM. PERFORM DYNPRO_SAPMF05A_0300 USING PREV_AMOUNT PREV_TEXT PREV_DUE_ON_DATE INFILE-POST_KEY INFILE-ACCNT INFILE-SPECIAL_GL. IF PREV_PK = '40' OR PREV_PK = '50'. PERFORM DYNPRO_SAPLKACB_0002 USING PREV_BUSINESS_AREA PREV_ORDER. ENDIF. IF PREV_DOLLAR_AMT LT 0. ADD: PREV_DOLLAR_AMT TO AMT_CREDIT_ADDED. ELSE. ADD: PREV_DOLLAR_AMT TO AMT_DEBIT_ADDED. ENDIF. ADD: 1 TO DETAIL_REC_CNT. ENDFORM. ************************************************************************ * Dynpro for program SAPMF05A Screen 0100 FORM DYNPRO_SAPMF05A_0100 USING POST_KEY POST_ACCNT. *----------------------------------------------------------------------- * This FORM formats SCREEN 0100 *----------------------------------------------------------------------- * This PERFORM is done once for each screen. PERFORM BDC_DYNPRO USING 'SAPMF05A' '0100'. * This PERFORM is done as many times as there are fields to be * populated for the screen being processed. PERFORM BDC_VALUE USING 'BKPF-BLDAT' HEADER-DOC_MDY. PERFORM BDC_VALUE USING 'BKPF-BUDAT' HEADER-POST_MDY. PERFORM BDC_VALUE USING 'BKPF-BLART' HEADER-DOC_TYPE. PERFORM BDC_VALUE USING 'BKPF-BUKRS' HEADER-COMPANY_CODE. PERFORM BDC_VALUE USING 'BKPF-MONAT' HEADER-PERIOD. PERFORM BDC_VALUE USING 'BKPF-WAERS' HEADER-CURRENCY. PERFORM BDC_VALUE USING 'BKPF-XBLNR' HEADER-REFERENCE_DOC. PERFORM BDC_VALUE USING 'BKPF-BKTXT' HEADER-TEXT. PERFORM BDC_VALUE USING 'RF05A-NEWBS' POST_KEY. PERFORM BDC_VALUE USING 'RF05A-NEWKO' POST_ACCNT. PERFORM BDC_VALUE USING 'RF05A-NEWUM' INFILE-SPECIAL_GL. ENDFORM. ************************************************************************ * Dynpro for program SAPMF05A Screen 0300 FORM DYNPRO_SAPMF05A_0300 USING AMOUNT TEXT DUE_ON_DATE POST_KEY POST_ACCNT SPECIAL_GL. *----------------------------------------------------------------------- * This FORM formats SCREEN 0300 *----------------------------------------------------------------------- * This PERFORM is done once for each screen. IF PREV_PK = '01' OR PREV_PK = '11'. PERFORM BDC_DYNPRO USING 'SAPMF05A' '0301'. ELSEIF PREV_PK = '09' OR PREV_PK = '19'. PERFORM BDC_DYNPRO USING 'SAPMF05A' '0303'. PERFORM BDC_VALUE USING 'BSEG-ZFBDT' HEADER-DOC_MDY. ELSE. PERFORM BDC_DYNPRO USING 'SAPMF05A' '0300'. ENDIF. * This PERFORM is done as many times as there are fields to be * populated for the screen being processed. PERFORM BDC_VALUE USING 'BSEG-WRBTR' AMOUNT. PERFORM BDC_VALUE USING 'RF05A-NEWBS' POST_KEY. PERFORM BDC_VALUE USING 'RF05A-NEWKO' POST_ACCNT. PERFORM BDC_VALUE USING 'RF05A-NEWUM' SPECIAL_GL. IF TEXT NE SPACE. PERFORM BDC_VALUE USING 'BSEG-SGTXT' TEXT. ENDIF. IF DUE_ON_DATE NE SPACE. PERFORM BDC_VALUE USING 'BSEG-ZFBDT' DUE_ON_DATE. ENDIF. IF NO_BA_FLG = 'N'. IF PREV_PK = '09' OR PREV_PK = '19' OR PREV_PK = '11' OR PREV_PK = '01'. PERFORM BDC_VALUE USING 'BSEG-GSBER' PREV_BUSINESS_AREA. ENDIF. ENDIF. ENDFORM. ************************************************************************ * Dynpro for program SAPLKACB Screen 0002 FORM DYNPRO_SAPLKACB_0002 USING BUSINESS_AREA ORDER. *----------------------------------------------------------------------- * This FORM formats SCREEN 0002 WHICH IS A POP-UP SCREEN * THAT DOES NOT APPEAR DURING ON-LINE PROCESSING *----------------------------------------------------------------------- * This PERFORM is done once for each screen. PERFORM BDC_DYNPRO USING 'SAPLKACB' '0002'. * This PERFORM is done as many times as there are fields to be * populated for the screen being processed. IF BUSINESS_AREA NE '700'. PERFORM BDC_VALUE USING 'COBL-GSBER' BUSINESS_AREA. ENDIF. IF ORDER NE SPACE. PERFORM BDC_VALUE USING 'COBL-AUFNR' ORDER. ENDIF. ENDFORM. ************************************************************************ * BDC Dynpro FORM BDC_DYNPRO USING PGM SCRN. *----------------------------------------------------------------------- * This FORM formats the transaction that tells the BDC which screen is * to be populated. *----------------------------------------------------------------------- CLEAR BDC_TAB. MOVE: PGM TO BDC_TAB-PROGRAM, SCRN TO BDC_TAB-DYNPRO, BEGIN TO BDC_TAB-DYNBEGIN. APPEND BDC_TAB. ENDFORM. ************************************************************************ * BDC Value FORM BDC_VALUE USING FIELD VAL. *----------------------------------------------------------------------- * This FORM tells the BDC which field is to be populated and the value * to use. *----------------------------------------------------------------------- CLEAR BDC_TAB. MOVE: FIELD TO BDC_TAB-FNAM, VAL TO BDC_TAB-FVAL. APPEND BDC_TAB. ENDFORM. ************************************************************************ FORM OPEN_BDC. *----------------------------------------------------------------------- * This routine opens the BDC data file *----------------------------------------------------------------------- SY-SUBRC = 0. CALL FUNCTION 'BDC_OPEN_GROUP' EXPORTING CLIENT = SY-MANDT GROUP = GROUP_NAME KEEP = 'X' USER = SY-UNAME 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 NE 0. MOVE: TRUE TO ABEND_JOB. CASE SY-SUBRC. WHEN 01. PERFORM PROCESS_MSG USING '109' SY-MANDT 'BDC OPEN' ''. WHEN 02. PERFORM PROCESS_MSG USING '109' 'BDC OPEN' '' ''. WHEN 03. PERFORM PROCESS_MSG USING '111' 'BDC OPEN' '' ''. WHEN 04. PERFORM PROCESS_MSG USING '124' 'BDC OPEN' '' ''. WHEN 05. PERFORM PROCESS_MSG USING '112' 'BDC OPEN' '' ''. WHEN 06. PERFORM PROCESS_MSG USING '113' 'BDC OPEN' '' ''. WHEN 07. PERFORM PROCESS_MSG USING '114' 'BDC OPEN' '' ''. WHEN 08. PERFORM PROCESS_MSG USING '115' 'BDC OPEN' '' ''. WHEN 09. PERFORM PROCESS_MSG USING '125' 'BDC OPEN' '' ''. WHEN 10. PERFORM PROCESS_MSG USING '116' 'BDC OPEN' '' ''. WHEN 11. PERFORM PROCESS_MSG USING '126' 'BDC OPEN' '' ''. ENDCASE. ELSE. MOVE: TRUE TO BDC_OPENNED, FALSE TO NEW_BDC. ENDIF. ENDFORM. ************************************************************************ * Insert BDC data FORM INSERT_BDCDATA. *----------------------------------------------------------------------- * This routine inserts a scenario into the BDC batch session. * Add the actual value of the particular Transaction code relevant * to the scenario being processed for the constant TRANS_CODE. *----------------------------------------------------------------------- SY-SUBRC = 0. CALL FUNCTION 'BDC_INSERT' EXPORTING TCODE = TRANS_CODE TABLES DYNPROTAB = BDC_TAB EXCEPTIONS INTERNAL_ERROR = 1 NOT_OPEN = 2 QUEUE_ERROR = 3 TCODE_INVALID = 4 OTHERS = 5. IF SY-SUBRC NE 0. MOVE: TRUE TO ABEND_JOB. CASE SY-SUBRC. WHEN 01. PERFORM PROCESS_MSG USING '113' 'BDC INSERT' '' ''. WHEN 02. PERFORM PROCESS_MSG USING '117' 'BDC INSERT' '' ''. WHEN 03. PERFORM PROCESS_MSG USING '114' 'BDC INSERT' '' ''. WHEN 04. PERFORM PROCESS_MSG USING '118' 'BDC INSERT' '' ''. WHEN 05. PERFORM PROCESS_MSG USING '126' 'BDC INSERT' '' ''. ENDCASE. ELSE. BDC_TRANS_CNT = BDC_TRANS_CNT + 1. ENDIF. * Initialize table after inserting the processed BDC Transactions * for one scenario REFRESH BDC_TAB. ENDFORM. ************************************************************************ * End of Job Routine FORM EOJ_ROUTINE. IF BDC_OPENNED = TRUE. PERFORM CLOSE_BDC. IF BDC_TAB_CREATED = TRUE AND ABEND_JOB = FALSE. TRANSLATE SUBMIT TO UPPER CASE. IF SUBMIT = 'X'. PERFORM SUBMIT_BDC_TO_BATCH. ENDIF. ENDIF. ENDIF. IF ABEND_JOB = TRUE. PERFORM ABEND_JOB. PERFORM ALERT_CHECK. ELSE. WRITE: /1 ' End of Job Run'. TRANSLATE IN_TRAILER-INTERFACE_ID TO UPPER CASE. IF IN_TRAILER-INTERFACE_ID NE 'AR01'. SELECT UNIX_NAME PRINTER CONTACT INTO (TEMP_UNIX_NAME, TEMP_PRINTER, TEMP_CONTACT) FROM ZMETA WHERE ID EQ IN_TRAILER-INTERFACE_ID. ENDSELECT. IF SY-SUBRC NE 0. SY-SUBRC = 0. ENDIF. ENDIF. TRANSLATE TEMP_UNIX_NAME TO LOWER CASE. SHIFT FULL_FIL_NAME UP TO TEMP_UNIX_NAME+0(9). SUBMIT ZUXMV WITH FILENAME EQ FULL_FIL_NAME WITH FROMPATH EQ TEMP_UNIX_PATH WITH TO_PATH EQ TEMP_ARC_PATH AND RETURN. ENDIF. SUBMIT ZUXLP WITH FILENAME = TEMP_LOG_NAME WITH PATH = TEMP_LOG_PATH WITH PRINTER = TEMP_PRINTER AND RETURN. IF ABEND_JOB = TRUE. IF EXECUTION = 'ONLINE'. MESSAGE A100 WITH IN_TRAILER-INTERFACE_ID. ENDIF. ENDIF. CLOSE DATASET LOGFILE. ENDFORM. * Close BDC data FORM CLOSE_BDC. *----------------------------------------------------------------------- * This routine closes the BDC batch session. *----------------------------------------------------------------------- SY-SUBRC = 0. CALL FUNCTION 'BDC_CLOSE_GROUP' EXCEPTIONS NOT_OPEN = 1 QUEUE_ERROR = 2 OTHERS = 3. IF SY-SUBRC NE 0. MOVE: TRUE TO ABEND_JOB. CASE SY-SUBRC. WHEN 01. PERFORM PROCESS_MSG USING '117' 'BDC CLOSE' '' ''. WHEN 02. PERFORM PROCESS_MSG USING '114' 'BDC CLOSE' '' ''. WHEN 03. PERFORM PROCESS_MSG USING '126' 'BDC CLOSE' '' ''. ENDCASE. ENDIF. ENDFORM. ************************************************************************ * Abend Job FORM ABEND_JOB. *----------------------------------------------------------------------- * This form updates the Interface Date/Time Control File with a status * of 'A' to indicate that this Interface has abended. The Date/Time * stamp on the Control file will not be updated with the date/time * from the current file. The parameter FILE_OPERATION OF '3' initiates * this process. Any time Operation '3' is used with the * Date/Time Control File, the calling program must abend using an 'A' * Message. A generic abend message of 100 has been set up in the * T100 table. *----------------------------------------------------------------------- CALL FUNCTION 'Z_PROCESS_INTERFACE_CTL_TABLE' EXPORTING FILE_ID = IN_TRAILER-INTERFACE_ID FILE_NAME = IN_TRAILER-FILE_NAME FILE_DATE = IN_TRAILER-DATE FILE_TIME = IN_TRAILER-TIME FILE_OPERATION = '3' EXCEPTIONS DUP_FILE_ERROR = 1 FILE_ID_NOT_FOUND = 2 TABLE_NOT_UPDATED = 3 OTHERS = 4. IF SY-SUBRC NE 0. CASE SY-SUBRC. WHEN 01. PERFORM PROCESS_MSG USING '127' IN_TRAILER-INTERFACE_ID IN_TRAILER-FILE_NAME 'OPERATION 3'. WHEN 02. PERFORM PROCESS_MSG USING '128' IN_TRAILER-INTERFACE_ID IN_TRAILER-FILE_NAME 'OPERATION 3'. WHEN 03. PERFORM PROCESS_MSG USING '129' 'ZTAG' 'OPERATION 3' ''. WHEN 04. PERFORM PROCESS_MSG USING '126' 'OPERATION 3' '' ''. ENDCASE. ENDIF. PERFORM PROCESS_MSG USING '100' IN_TRAILER-INTERFACE_ID '' ''. ENDFORM. ************************************************************************ * Submit BDC to Batch FORM SUBMIT_BDC_TO_BATCH. *----------------------------------------------------------------------- * This FORM submits the completed BDC Table to Batch to be processed * for all the transactions processed from the Interface input file. *----------------------------------------------------------------------- SUBMIT RSBDCSUB WITH MAPPE EQ GROUP_NAME AND RETURN. ENDFORM. INCLUDE ZI000002.

1 comment:

Unknown said...

Give the t-code shdb in the command field.

Click the new recording button.

Give a name to the recording and the t-code you want to record.

E.g.:
Recording : Z_UPLOAD
Transaction code : F-02

When you click save, it takes you to t-code (F-02) you would like to do recording for upload.

Record carefully. Fill in the details you want to upload.
Then the Transaction recorder – edit recording Z_UPLOAD screen is displayed. You can edit your recording or just save it and click back button.

Select your recording and click create program button.

Enter the program name say Z_UPLOAD.Select the transfer from recording option. Save it.Give the program title, type as executable program and click source code button at the bottom.

That will generate the code automatically.

In the generated code all the upload FM, and mention the file name, filetype in the exporting parameters.

Give filetype as XLS. Hope this will do ur task.

link us...

For Visitors

if you want to publish or Add something on ERP, SAP , SAP FUNCTIONAL, SAP ABAP then mail us along with your email-id. contain must be yours

email-id :- avinashkr_raj@yahoo.com(any email)

email-id :- avinaskr_raj.abap@blogger.com ( use only gmail)