Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

source code needs for simple BDC session

Hi experts,

I have a Z table with 4 fields. i want to insert the records using bdc.

I am verymuch familier with Recording method. bt i am nt aware of the nxt method.

Can any one help this? how to make tht session method?

Plz paste a sample code for that....

Mohana

Tags:
replied

Hi Mohana this is Balu not bala,

Anyways,

I have coded for MM01 for notepad records uploading, i dont think there might be much difference with cutomized ztable .

If your screen that is designed is making the data save into the table means what ever that u record through SHDB taking the record code to program will reach your task.

sample which i have done for MM01.

*REPORT ZRY_BDCDIRECT_PROGRAM

  • no standard page heading line-size 255.

TYPES: BEGIN OF STU,

MATNR LIKE RMMG1-MATNR, "Material Number"

MBRSH LIKE RMMG1-MBRSH, "Industry Sector"

MTART LIKE RMMG1-MTART, "Material Type"

MAKTX LIKE MAKT-MAKTX, "Material Description"

MEINS LIKE MARA-MEINS, "Basic Unit of Measure"

END OF STU.

DATA WA_ITAB TYPE STU.

DATA ITAB TYPE TABLE OF STU.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\Documents and Settings
Desktop\BALU\ABC.TXT'

TABLES

DATA_TAB = ITAB.

.

IF SY-SUBRC <> 0.

ENDIF.

DATA WA_BDC TYPE BDCDATA.

DATA: BDCDATA TYPE BDCDATA.

DATA BDCITAB TYPE TABLE OF BDCDATA.

LOOP AT ITAB INTO WA_ITAB.

perform bdc_dynpro using 'SAPLMGMM' '0060'.

perform bdc_field using 'BDC_CURSOR'

'RMMG1-MTART'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RMMG1-MATNR'

WA_ITAB-MATNR. "'S1'.

perform bdc_field using 'RMMG1-MBRSH'

WA_ITAB-MBRSH. "'M'.

perform bdc_field using 'RMMG1-MTART'

WA_ITAB-MTART. "'VKHM'

perform bdc_dynpro using 'SAPLMGMM' '0070'.

perform bdc_field using 'BDC_CURSOR'

'MSICHTAUSW-DYTXT(01)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_field using 'MSICHTAUSW-KZSEL(01)'

'X'.

perform bdc_dynpro using 'SAPLMGMM' '4004'.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

perform bdc_field using 'MAKT-MAKTX'

WA_ITAB-MAKTX. " material

perform bdc_field using 'BDC_CURSOR'

'MARA-MEINS'.

perform bdc_field using 'MARA-MEINS'

WA_ITAB-MEINS. "'KG'

perform bdc_field using 'MARA-MTPOS_MARA'

'NORM'.

*WA_BDC-PROGRAM = 'SAPLMGMM'.

*WA_BDC-DYNPRO = '0060'.

*WA_BDC-DYNBEGIN = 'X'.

*WA_BDC-FNAM = 'BDC_CURSOR'.

*WA_BDC-FVAL = 'RMMG1-MTART'.

*

*PERFORM APPEND.

*WA_BDC-FNAM = 'BDC_OKCODE'.

*WA_BDC-FVAL = '/00'.

*

*PERFORM APPEND.

*WA_BDC-FNAM = 'RMMG1-MATNR'.

*WA_BDC-FVAL = WA_ITAB-MATNR.

*

*PERFORM APPEND.

*WA_BDC-FNAM = 'RMMG1-MBRSH'.

*WA_BDC-FVAL = WA_ITAB-MBRSH.

*

*PERFORM APPEND.

*WA_BDC-FNAM = 'RMMG1-MTART'.

*WA_BDC-FVAL = WA_ITAB-MTART.

*

*PERFORM APPEND.

*WA_BDC-PROGRAM = 'SAPLMGMM'.

*WA_BDC-DYNPRO = '0070'.

*WA_BDC-DYNBEGIN = 'X'.

*WA_BDC-FNAM = 'BDC_CURSOR'.

*WA_BDC-FVAL = 'MSICHTAUSW-DYTXT(01)'.

*

*PERFORM APPEND.

*WA_BDC-FNAM = 'BDC_OKCODE'.

*WA_BDC-FVAL = '=ENTR'.

*

*PERFORM APPEND.

*WA_BDC-FNAM = 'MSICHTAUSW-KZSEL(01)'.

*WA_BDC-FVAL = 'X'.

*

*PERFORM APPEND.

*WA_BDC-PROGRAM = 'SAPLMGMM'.

*WA_BDC-DYNPRO = '4004'.

*WA_BDC-DYNBEGIN = 'X'.

*WA_BDC-FNAM = 'BDC_OKCODE'.

*WA_BDC-FVAL = '/00'.

*

*PERFORM APPEND.

*WA_BDC-FNAM = 'MAKT-MAKTX'.

*WA_BDC-FVAL = 'WA_ITAB-MAKTX'.

*

*PERFORM APPEND.

*WA_BDC-FNAM = 'MARA-MEINS'.

*WA_BDC-FVAL = 'WA_ITAB-MEINS'.

*

*PERFORM APPEND.

CALL TRANSACTION 'MM01' USING BDCITAB MODE 'A'.

REFRESH BDCITAB.

ENDLOOP.

*----


*

  • Start new screen

*

*----


*

FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR BDCDATA.

BDCDATA-PROGRAM = PROGRAM.

BDCDATA-DYNPRO = DYNPRO.

BDCDATA-DYNBEGIN = 'X'.

APPEND BDCDATA TO BDCITAB.

CLEAR BDCDATA.

ENDFORM.

*----


*

  • Insert field

*

*----


*

FORM BDC_FIELD USING FNAM FVAL.

  • IF FVAL <> NODATA.

CLEAR BDCDATA.

BDCDATA-FNAM = FNAM.

BDCDATA-FVAL = FVAL.

APPEND BDCDATA TO BDCITAB.

CLEAR BDCDATA.

  • ENDIF.

ENDFORM.

*FORM APPEND.

*APPEND WA_BDC TO BDCITAB.

*CLEAR WA_BDC.

*ENDFORM.

If still not solved let me know the problem exactly.

Hope my answer helps you.

Cheers!!

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question