http://moryhanry.com/sapbdcwritetransfer.html SAP SM35 BDC RECORDING PROCEDURE SAP SM35 BDC RECORDING 1. Go to SAP Tcode SM35 . 2. Press “RECORDING” 3. Enter the recording session name [always start with Z] use “CREATE” function. 4. Enter Tcode to be used in the session. Press “ENTER”. 5. Enter the required data in the corresponding screen in SAP & make change if necessary. Press “SAVE”. [During this whole process, the BDC records the movements of the cursor and the data change made in these field , so do not repeat any cursor movements which can re-record the movement and go back to a field where the data has been changed or entered] 6. In Batch Input will appear Recording screen , listing the screens, data fields, etc recorded. 7. Press “GET TRANSACTION”. SAVE the recording. 8. Go back [F3] to the previous screen. Press “OVERVIEW” “Recording: Overview” will appear. Choose the "recording done" Press "GENERATE PROGRAM". A popup appears and enter the Program name [start the name with Z always] Press "ENTER". 9. Enter the title of the program Enter the other attributes : Type - 1[Online program], Status - T[Test program] Application - *[Not application-specific]. SAVE the attributes of the program & create the object as a LOCAL OBJECT. 10. Press "SOURCE CODE" and the code generated by the program is displayed. 11. To check the program created, Change the data back to the original values as in the original record.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
http://moryhanry.com/sapbdcwritetransfer.html
SAP SM35BDC RECORDING PROCEDURE
SAP SM35 BDC RECORDING
1. Go to SAP Tcode SM35 . 2. Press “RECORDING”
3. Enter the recording session name [always start with Z] use “CREATE” function.
4. Enter Tcode to be used in the session. Press “ENTER”.
5. Enter the required data in the corresponding screen in SAP & make change if necessary. Press “SAVE”. [During this whole process, the BDC records the movements of the cursor and the data change made in these field , so do not repeat any cursor movements which can re-record the movement and go back to a field where the data has been changed or entered] 6. In Batch Input will appear Recording screen , listing the screens, data fields, etc recorded. 7. Press “GET TRANSACTION”. SAVE the recording. 8. Go back [F3] to the previous screen. Press “OVERVIEW” “Recording: Overview” will appear. Choose the "recording done" Press "GENERATE PROGRAM". A popup appears and enter the Program name [start the name with Z always] Press "ENTER". 9. Enter the title of the program Enter the other attributes : Type - 1[Online program], Status - T[Test program] Application - *[Not application-specific]. SAVE the attributes of the program & create the object as a LOCAL OBJECT. 10. Press "SOURCE CODE" and the code generated by the program is displayed. 11. To check the program created, Change the data back to the original values as in the original record. Check the program for any syntax errors. Use the menu path - Program > Execute. Enter the name of the session & the authorization group for the session. Press "EXECUTE" [F8]. Use T/CodeSM35 to go back to the "BDC session overview".
6. Click to check if the session ran successfully without error .
7. Return to “Batch Input: Log Overview” screen.
8. Highlight the session and
click
9. This will be appeared
NoteIf any errors are encountered during the SAP background processing the session will be written to the ‘Incorrect’ tab of the “Batch Input: Session Overview” screen.
These errors will need to be looked into by BCPO or the Office of Attorney General’s Comptroller’s Office.
13. After Complete Click on "Program Button" in Application Tollbar Program name : Give Z/Y name for generate SE38 program Field Content : Select "transfer from recording "
* Inserting a Tab Delimited between the Fields in the Internal Table ** This program allows you to insert any Tab Delimited characters easily.** You have to create the customized Function in SE37 First.** The customized functions will replace all the fields in your internal table* with your desired Tab Delimited characters.** Written by : SAP Basis, ABAP Programming and Other IMG Stuff* http://www.sap-img.com***Replace DELIMIT with "," in the function
DATA: BEGIN OF ITAB OCCURS 100, TXT01(10), TXT02(10), END OF ITAB.
SELECTION-SCREEN BEGIN OF BLOCK FILE_OP WITH FRAME TITLE TEXT-030.SELECTION-SCREEN BEGIN OF LINE.PARAMETERS: DLOAD AS CHECKBOX DEFAULT ' '.SELECTION-SCREEN COMMENT 4(30) TEXT-027.PARAMETERS: FILE LIKE RLGRAP-FILENAME DEFAULT 'C:\TEMP\ZTEST.TXT'.SELECTION-SCREEN END OF LINE.
************************************************** This Function modules need to be created first.*************************************************FUNCTION Z_DELIMIT_DOWNLOAD .*"----------------------------------------------------------------------*"*"Local interface:*" IMPORTING*" REFERENCE(DELIMIT)*" TABLES*" INTAB*" OUTTAB*"----------------------------------------------------------------------
FIELD-SYMBOLS: <F>.
DATA: LEN TYPE I, NUM TYPE I, DELIMIT_LEN TYPE I.
DELIMIT_LEN = STRLEN( DELIMIT ).
LOOP AT INTAB. CLEAR OUTTAB. NUM = 0. DO.* Get name of next structure field into <f> ASSIGN COMPONENT SY-INDEX OF STRUCTURE INTAB TO <F>. IF SY-SUBRC <> 0. EXIT. ENDIF. " No more fields in structure
LEN = STRLEN( <F> ). WRITE: <F> TO OUTTAB+NUM(LEN). " Write field to output table NUM = NUM + LEN.
WRITE: DELIMIT TO OUTTAB+NUM(DELIMIT_LEN). NUM = NUM + DELIMIT_LEN. ENDDO. APPEND OUTTAB. ENDLOOP.ENDFUNCTION.
Example how Views are dealt in BDC
Can any body tell me some views of MM that we can use in BDC?
Rashi
Well here is an example for you to see how the views are dealt with in BDC's...
*********************************************************This is a BDC for Semi finished Materials********report ZBDC_SEMIFIN no standard page heading line-size 255.
include bdcrecx1.
Tables: Mara,"General Material Data mard,"Storage Location Data for Material mvke,"Sales Data for Material Makt,"Material Descriptions marc,"Plant Data for Material mbew,"Material Valuation rlgrap."Program Fields/Screen Fields for SAPLGRAP
Data: begin of ITAB occurs 0,"Internal table for Semi-Finished Material
* Initial data matnr like mara-matnr, "Material Code mbrsh like mara-mbrsh, "Industry Data mtart like mara-mtart, "Material Type
* Org Data Werks like marc-werks, "Plant lgort like mard-lgort, "Storage Location vkorg like mvke-vkorg, "Sales Orgnization vtweg like mvke-vtweg, "Distribution Chanel
* Basic 1 Maktx Like makt-maktx, "Description meins like mara-meins, "Uom matkl like mara-matkl, "Material Group BISMT LIKE MARA-BISMT, " Old Material Number spart like mara-spart, "Division
brgew(7),"like mara-brgew, "Gross Weight gewei like MARA-GEWEI, "Weight Unit ntgew(7)," like mara-ntgew, "Net Weight
* Purchasing MAKTL LIKE MARA-MATKL, "Material Group ekwsl like MARA-EKWSL, " Purchasing Value Key ekgrp like MARC-EKGRP, " Purchasing Group
* Mrp 1 disgr like MARC-DISGR, "Mrp Group* ekgrp like MARC-EKGRP, "Purchasing group dismm like MARC-DISMM, "Mrp Type dispo like MARC-DISPO, "Mrp Controller disls like MARC-DISLS, "Lot Size BSTMI like MARC-BSTMI, BSTMA like MARC-BSTMA, BSTRF like MARC-BSTRF, BSTFE like MARC-BSTFE,
* Mrp 2 beskz like MARC-BESKZ, "Procurement type lgpro like MARC-LGPRO, "Production Storage Location dzeit(3),"like MARC-DZEIT, "In house Production time plifz(3),"like MARC-PLIFZ, "Planned delivery time fhori(3),"like MARC-FHORI, "Sched margin key eisbe like MARC-EISBE, "Safety stock
* Mrp 3 PERKZ LIKE MARC-PERKZ, vrmod like MARC-VRMOD, "Consumption mode vint1(3)," like MARC-VINT1, "Backward Consumption period vint2(3),"like MARC-VINT2, "Forward Consumption period mtvfp like MARC-MTVFP, "Availability Check
* Mrp 4 sbdkz like MARC-SBDKZ, "Individual/ Collective SAUFT like MARC-SAUFT, "Repetitive Manufacturing SFEPR like MARC-SFEPR, "REM Profile
* Work Scheduling View ausme like MARC-AUSME, "Unit of issue FEVOR LIKE MARC-FEVOR, "Production Scheduler SFCPF like MARC-SFCPF, "Production Scheduler Profile umren(5)," like RMMZU-UMREN, "Val for base uom umrez(5) ,"like RMMZU-UMREz, "Value for uo issue
* Accounting 1 bklas like MBEW-BKLAS, "Valuation Class vprsv like MBEW-VPRSV, "Price Control Indicator verpr(7)," like MBEW-VERPR, "Value/Price STPRS like MBEW-STPRS,
*COSTING EKALR LIKE MBEW-EKALR," With qty str
LOSGR like MARC-LOSGR, " Costing Lot size end of ITAB.
**********************************************************Data: W_record type I, "Record Allready exists. w_trecord type I. "Total record processed
start-of-selection.perform upload. "Upload Data from Text File
if w_trecord gt 0 or w_record gt 0. perform batch_job.endif.
perform close_group. "Close session
FORM SEMI.loop at ITAB.* Check for material in master ************************* select single * from mara where matnr eq ITAB-matnr. if sy-subrc ne 0. w_trecord = w_trecord + 1.
*Initial Screenperform bdc_dynpro using 'SAPLMGMM' '0060'.perform bdc_field using 'BDC_CURSOR' 'RMMG1-MTART'.perform bdc_field using 'BDC_OKCODE' '=AUSW'.perform bdc_field using 'RMMG1-MATNR' ITAB-MATNR.perform bdc_field using 'RMMG1-MBRSH' 'M'.perform bdc_field using 'RMMG1-MTART' 'HALB'.***********************Views***********************************Select Viewsperform bdc_dynpro using 'SAPLMGMM' '0070'.perform bdc_field using 'BDC_CURSOR' 'MSICHTAUSW-DYTXT(17'.perform bdc_field using 'BDC_OKCODE' '/00'.perform bdc_field using 'MSICHTAUSW-KZSEL(01)' 'X'.perform bdc_field using 'MSICHTAUSW-KZSEL(09)' 'X'.perform bdc_field using 'MSICHTAUSW-KZSEL(12)' 'X'.perform bdc_field using 'MSICHTAUSW-KZSEL(13)' 'X'.perform bdc_field using 'MSICHTAUSW-KZSEL(14)'
'X'.perform bdc_field using 'MSICHTAUSW-KZSEL(15)' 'X'..perform bdc_field using 'MSICHTAUSW-KZSEL(17)' 'X'.***********************Views**********************************
*perform bdc_dynpro using 'SAPLMGMM' '0070'.*perform bdc_field using 'BDC_CURSOR'* 'MSICHTAUSW-DYTXT(01)'.*perform bdc_field using 'BDC_OKCODE'* '/00'.*perform bdc_dynpro using 'SAPLMGMM' '0070'.*perform bdc_field using 'BDC_CURSOR'* 'MSICHTAUSW-DYTXT(17)'.*perform bdc_field using 'BDC_OKCODE'* '/00'.*perform bdc_field using 'MSICHTAUSW-KZSEL(17)'* ITAB-KZSEL_17_011.*perform bdc_dynpro using 'SAPLMGMM' '0070'.*perform bdc_field using 'BDC_CURSOR'* 'MSICHTAUSW-DYTXT(01)'.*perform bdc_field using 'BDC_OKCODE'* '/00'.*perform bdc_dynpro using 'SAPLMGMM' '0070'.*perform bdc_field using 'BDC_CURSOR'* 'MSICHTAUSW-DYTXT(13)'.*perform bdc_field using 'BDC_OKCODE'* '=ENTR'.*perform bdc_field using 'MSICHTAUSW-KZSEL(13)'* ITAB-KZSEL_13_012.
*Org Dataperform bdc_dynpro using 'SAPLMGMM' '0080'.perform bdc_field using 'BDC_CURSOR' 'RMMG1-LGORT'.perform bdc_field using 'BDC_OKCODE' '=ENTR'.perform bdc_field using 'RMMG1-WERKS' ITAB-WERKS.perform bdc_field using 'RMMG1-LGORT' ITAB-LGORT.
*Basic 1perform bdc_dynpro using 'SAPLMGMM' '4004'.perform bdc_field using 'BDC_OKCODE' '=SP09'.perform bdc_field using 'MAKT-MAKTX' ITAB-MAKTX.perform bdc_field using 'MARA-MEINS' ITAB-MEINS.perform bdc_field using 'MARA-MATKL' ITAB-MATKL.perform bdc_field using 'MARA-BISMT' ITAB-BISMT.perform bdc_field using 'MARA-SPART' ITAB-SPART.
perform bdc_field using 'MARA-MTPOS_MARA' 'NORM'.perform bdc_field using 'BDC_CURSOR' 'MARA-NTGEW'.perform bdc_field using 'MARA-BRGEW' ITAB-BRGEW.perform bdc_field using 'MARA-GEWEI' ITAB-GEWEI.perform bdc_field using 'MARA-NTGEW' ITAB-NTGEW.
*Purchasingperform bdc_dynpro using 'SAPLMGMM' '4000'.perform bdc_field using 'BDC_OKCODE' '=SP12'.perform bdc_field using 'MAKT-MAKTX' ITAB-MAKTX.perform bdc_field using 'MARA-MEINS' ITAB-MEINS.perform bdc_field using 'MARC-EKGRP' ITAB-EKGRP.perform bdc_field using 'MARA-MATKL' ITAB-MATKL.perform bdc_field using 'BDC_CURSOR' 'MARA-EKWSL'.perform bdc_field using 'MARA-EKWSL' ITAB-EKWSL.
*MRP 1perform bdc_dynpro using 'SAPLMGMM' '4000'.perform bdc_field using 'BDC_OKCODE' '=SP13'.perform bdc_field using 'MAKT-MAKTX' ITAB-MAKTX.perform bdc_field using 'MARA-MEINS' ITAB-MEINS.perform bdc_field using 'MARC-EKGRP' ITAB-EKGRP.perform bdc_field using 'MARC-DISMM' ITAB-DISMM.perform bdc_field using 'MARC-DISPO' ITAB-DISPO.perform bdc_field using 'BDC_CURSOR' 'MARC-DISLS'.perform bdc_field using 'MARC-DISLS' ITAB-DISLS.IF ITAB-DISLS EQ 'EX' .perform bdc_field using 'MARC-BSTMI' ITAB-BSTMI."MIN LOT SIZEperform bdc_field using 'MARC-BSTMA' ITAB-BSTMA."MAX LOT SIZEperform bdc_field using 'MARC-BSTRF' ITAB-BSTRF."RNDINGELSEIF ITAB-DISLS EQ 'FX'.perform bdc_field using 'MARC-BSTFE' ITAB-BSTFE.
ENDIF.
*MRP 2perform bdc_dynpro using 'SAPLMGMM' '4000'.perform bdc_field using 'BDC_OKCODE' '=SP14'.perform bdc_field using 'MAKT-MAKTX' ITAB-MAKTX.perform bdc_field using 'MARC-BESKZ' ITAB-BESKZ.perform bdc_field using 'MARC-LGPRO' ITAB-LGPRO.perform bdc_field using 'MARC-DZEIT' ITAB-DZEIT.perform bdc_field using 'MARC-PLIFZ' ITAB-PLIFZ.perform bdc_field using 'MARC-FHORI' ITAB-FHORI.perform bdc_field using 'BDC_CURSOR' 'MARC-EISBE'.perform bdc_field using 'MARC-EISBE' ITAB-EISBE.
*MRP 3perform bdc_dynpro using 'SAPLMGMM' '4000'.perform bdc_field using 'BDC_OKCODE' '=SP15'.perform bdc_field using 'MAKT-MAKTX' ITAB-MAKTX.perform bdc_field using 'MARC-PERKZ' ITAB-PERKZ.perform bdc_field using 'MARC-VRMOD' ITAB-VRMOD.perform bdc_field using 'MARC-VINT1' ITAB-VINT1.perform bdc_field using 'MARC-VINT2' ITAB-VINT2.perform bdc_field using 'BDC_CURSOR' 'MARC-MTVFP'.perform bdc_field using 'MARC-MTVFP' ITAB-MTVFP.
*MRP 4perform bdc_dynpro using 'SAPLMGMM' '4000'.perform bdc_field using 'BDC_OKCODE' '=SP17'.perform bdc_field using 'MAKT-MAKTX' ITAB-MAKTX.perform bdc_field using 'MARC-SBDKZ' ITAB-SBDKZ.perform bdc_field using 'BDC_CURSOR' 'MARC-SFEPR'.perform bdc_field using 'MARC-SAUFT' ITAB-SAUFT.perform bdc_field using 'MARC-SFEPR' ITAB-SFEPR.
*Work Schedulingperform bdc_dynpro using 'SAPLMGMM' '4000'.perform bdc_field using 'BDC_OKCODE' '=SP24'.perform bdc_field using 'MAKT-MAKTX' ITAB-MAKTX.perform bdc_field using 'BDC_CURSOR' 'MARC-SFCPF'.perform bdc_field using 'MARA-MEINS' ITAB-MEINS.perform bdc_field using 'MARC-FEVOR' ITAB-FEVOR.perform bdc_field using 'MARC-LGPRO' ITAB-LGPRO.perform bdc_field using 'MARC-SFCPF' ITAB-SFCPF.perform bdc_field using 'MARC-DZEIT' ITAB-DZEIT.
*Check for Conversation Factor if ITAB-MEINS ne iTAB-ausme and iTAB-umren gt 0 and iTAB-umrez gt 0.
perform bdc_dynpro using 'SAPLMGMM' '0510'. perform bdc_field using: 'BDC_OKCODE' '=ENTR', 'RMMZU-UMREN' ITAB-UMREN, 'RMMZU-UMREZ' ITAB-UMREZ. endif.perform bdc_field using 'MARC-LGPRO' itab-LGPRO.perform bdc_field using 'MARC-DZEIT' itab-DZEIT.
*Accountingperform bdc_dynpro using 'SAPLMGMM' '4000'.perform bdc_field using 'BDC_OKCODE' '=SP26'.perform bdc_field using 'MAKT-MAKTX' ITAB-MAKTX.perform bdc_field using 'MARA-MEINS' ITAB-MEINS.perform bdc_field using 'MARA-SPART' ITAB-SPART.perform bdc_field using 'BDC_CURSOR' 'MBEW-STPRS'.perform bdc_field using 'MBEW-BKLAS' ITAB-BKLAS.perform bdc_field using 'MBEW-VPRSV' ITAB-VPRSV.perform bdc_field using 'MBEW-STPRS' ITAB-STPRS.IF ITAB-VPRSV = 'S'.perform bdc_field using 'MBEW-STPRS' "FILLS STD PRICE ITAB-VERPR.ELSEIF ITAB-VPRSV ='V'.
perform bdc_field using 'MBEW-VERPR' "FILLS VALUE ITAB-VERPR.ENDIF.
*Cost Estimateperform bdc_dynpro using 'SAPLMGMM' '4000'.perform bdc_field using 'BDC_OKCODE' '=BU'.perform bdc_field using 'MAKT-MAKTX' ITAB-MAKTX.perform bdc_field using 'BDC_CURSOR' 'MARC-PRCTR'.perform bdc_field using 'MARA-MEINS' ITAB-MEINS.perform bdc_field using 'MBEW-EKALR' ITAB-EKALR.perform bdc_field using 'MARC-LOSGR' ITAB-LOSGR.perform bdc_transaction using 'MM01'.
if w_trecord gt 0. Write:/ 'Background Job has been Created for ', w_trecord right-justified, 'Semi-Fin', 80 ''.
write:/ 'Please follow the following steps to run this job', 80 ''.
write:/ 'as listed below.', 80 ''. format color col_normal. skip. write:/05 '1.Goto Transaction SM35', 80 ''. write:/05 '2.Select your Session Name', 80 ''. write:/05 '3.Click On Execute Button', 80 ''. endif. if w_record gt 0. format color col_negative. write:/ w_record ,'records already existed', 80 ''. format color off. endif. uline.endform.
http://www.sap-img.com/bdc.htm
BDC Example: Using Table Control in BDC
Among beginners, using table control in BDC is always a puzzle.
Following is a sample code of handling table control in BDC.
REPORT Y730_BDC5 .*HANDLING TABLE CONTROL IN BDCDATA : BEGIN OF IT_DUMMY OCCURS 0, DUMMY(100) TYPE C, END OF IT_DUMMY.DATA : BEGIN OF IT_XK01 OCCURS 0, LIFNR(10) TYPE C, BUKRS(4) TYPE C, EKORG(4) TYPE C, KTOKK(4) TYPE C, NAME1(30) TYPE C, SORTL(10) TYPE C, LAND1(3) TYPE C, SPRAS(2) TYPE C, AKONT(6) TYPE C, FDGRV(2) TYPE C, WAERS(3) TYPE C, END OF IT_XK01, BEGIN OF IT_BANK OCCURS 0, BANKS(3) TYPE C, BANKL(10) TYPE C, BANKN(10) TYPE C, KOINH(30) TYPE C, LIFNR(10) TYPE C, END OF IT_BANK.DATA : IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE, IT_BDCMSGCOLL LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
LOOP AT IT_XK01.REFRESH IT_BDCDATA.perform bdc_dynpro using 'SAPMF02K' '0100'.perform bdc_field using 'BDC_CURSOR' 'RF02K-REF_LIFNR'.perform bdc_field using 'BDC_OKCODE' '/00'.perform bdc_field using 'RF02K-LIFNR' IT_XK01-LIFNR.perform bdc_field using 'RF02K-BUKRS' IT_XK01-BUKRS.perform bdc_field using 'RF02K-EKORG' IT_XK01-EKORG.perform bdc_field using 'RF02K-KTOKK' IT_XK01-KTOKK.perform bdc_dynpro using 'SAPMF02K' '0110'.perform bdc_field using 'BDC_CURSOR' 'LFA1-TELX1'.perform bdc_field using 'BDC_OKCODE' '/00'.perform bdc_field using 'LFA1-NAME1' IT_XK01-NAME1.perform bdc_field using 'LFA1-SORTL' IT_XK01-SORTL.perform bdc_field using 'LFA1-LAND1' IT_XK01-LAND1.
perform bdc_field using 'LFA1-SPRAS' IT_XK01-SPRAS.perform bdc_dynpro using 'SAPMF02K' '0120'.perform bdc_field using 'BDC_CURSOR' 'LFA1-KUNNR'.perform bdc_field using 'BDC_OKCODE' '/00'.perform bdc_dynpro using 'SAPMF02K' '0130'.perform bdc_field using 'BDC_CURSOR' 'LFBK-KOINH(02)'.perform bdc_field using 'BDC_OKCODE' '=ENTR'.DATA : FNAM(20) TYPE C, IDX TYPE C. MOVE 1 TO IDX.LOOP AT IT_BANK WHERE LIFNR = IT_XK01-LIFNR. CONCATENATE 'LFBK-BANKS(' IDX ')' INTO FNAM. perform bdc_field using FNAM IT_BANK-BANKS.
CONCATENATE 'LFBK-BANKL(' IDX ')' INTO FNAM. perform bdc_field using FNAM IT_BANK-BANKL.
CONCATENATE 'LFBK-BANKN(' IDX ')' INTO FNAM. perform bdc_field using FNAM IT_BANK-BANKN.
CONCATENATE 'LFBK-KOINH(' IDX ')' INTO FNAM. perform bdc_field using FNAM IT_BANK-KOINH. IDX = IDX + 1.ENDLOOP.
perform bdc_dynpro using 'SAPMF02K' '0130'.perform bdc_field using 'BDC_CURSOR' 'LFBK-BANKS(01)'.perform bdc_field using 'BDC_OKCODE' '=ENTR'.perform bdc_dynpro using 'SAPMF02K' '0210'.perform bdc_field using 'BDC_CURSOR' 'LFB1-FDGRV'.perform bdc_field using 'BDC_OKCODE' '/00'.perform bdc_field using 'LFB1-AKONT' IT_XK01-AKONT.perform bdc_field using 'LFB1-FDGRV' IT_XK01-FDGRV.perform bdc_dynpro using 'SAPMF02K' '0215'.perform bdc_field using 'BDC_CURSOR' 'LFB1-ZTERM'.perform bdc_field using 'BDC_OKCODE' '/00'.perform bdc_dynpro using 'SAPMF02K' '0220'.perform bdc_field using 'BDC_CURSOR' 'LFB5-MAHNA'.perform bdc_field using 'BDC_OKCODE'
'/00'.perform bdc_dynpro using 'SAPMF02K' '0310'.perform bdc_field using 'BDC_CURSOR' 'LFM1-WAERS'.perform bdc_field using 'BDC_OKCODE' '/00'.perform bdc_field using 'LFM1-WAERS' IT_XK01-WAERS.perform bdc_dynpro using 'SAPMF02K' '0320'.perform bdc_field using 'BDC_CURSOR' 'WYT3-PARVW(01)'.perform bdc_field using 'BDC_OKCODE' '=ENTR'.perform bdc_dynpro using 'SAPLSPO1' '0300'.perform bdc_field using 'BDC_OKCODE' '=YES'.CALL TRANSACTION 'XK01' USING IT_BDCDATA MODE 'A' UPDATE 'S' MESSAGES INTO IT_BDCMSGCOLL.ENDLOOP.
FORM BDC_DYNPRO USING PROG SCR. CLEAR IT_BDCDATA. IT_BDCDATA-PROGRAM = PROG. IT_BDCDATA-DYNPRO = SCR. IT_BDCDATA-DYNBEGIN = 'X'. APPEND IT_BDCDATA.ENDFORM.
FORM BDC_FIELD USING FNAM FVAL. CLEAR IT_BDCDATA. IT_BDCDATA-FNAM = FNAM. IT_BDCDATA-FVAL = FVAL. APPEND IT_BDCDATA.ENDFORM.
Hope that would clear the matters for freshers.
BDC program for Purchase Info Records*&---------------------------------------------------------------------**& REPORT ZMM0069 **&---------------------------------------------------------------------**& Module : MM |*& Application : The program loads the Purchasing Inforecords |*& |*----------------------------------------------------------------------**| Modification Log |*| ---------------- |*| Programmer Date CC# Chg.Ref Description of*| Change |*| ------------- ----------- ---- ----------- ----------------------|*| Rajesh Singh 23-AUG-2005 Initial*| development. |*----------------------------------------------------------------------*
REPORT zmm0069 NO STANDARD PAGE HEADING MESSAGE-ID z0 LINE-SIZE 132 LINE-COUNT 65(2).
** 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 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.
** 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.
*&---------------------------------------------------------------------**& 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 .
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*----------------------------------------------------------------------*
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*----------------------------------------------------------------------*
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*----------------------------------------------------------------------*
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*----------------------------------------------------------------------*
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.*&---------------------------------------------------------------------**& 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