Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

source code needs for simple BDC session

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Mohana,

Conform me whether you are updateing the records with Notepad or EXCEL sheet.

Based on that i will try to send you code.

Cheers!!

13 REPLIES 13

Former Member
0 Kudos

Mohana

Refer to the function modules BDC_OPEN_GROUP, BDC_INSERT and BDC_CLOSE_GROUP.

Thanks

Amol Lohade

0 Kudos

Hai,

I Dont want SHDB method...i need call session method.

Can any one please paste there code if available?........:-)

Mohana

0 Kudos

Ok. Just search in SDN with the term Session Method, you will get lot of results..

Regards,

Vishwa.

Former Member
0 Kudos

Hi,

Once you completed the recording in SHDB. select that recording and press Shift+f5 or goto Edit->Create Program.

This will create the program itself. You can do modification if necessary

Cheers,

Kothand

Former Member
0 Kudos

Hi

Once u do the recording in SHDB, select the recording and generate a program... save the program.

Now, bring the values of the 4 fields into an internal table.

Then Loop the internal table to the subroutines.

Loop at itab.

Perform bdc_field using xxx-xxxx itab-xxxx.(next to the field u have to give the itab-xxx which the field which holds ur values.

endloop.

Regards,

Vishwa.

Former Member
0 Kudos

Hi

If your requirement is to update

Z table with 4 fields

It will be more easy to directly update

using

INSERT / MODIFY / UPDATE statements instead of BDC

Regards

MD

Former Member
0 Kudos

hi mohana....

plz go through this link

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d4c5e890-0201-0010-bd9a-c3fd8683...

thanks

nikita

Edited by: nikita mishra on Sep 26, 2008 1:30 PM

Former Member
0 Kudos

Hi Mohana,

Conform me whether you are updateing the records with Notepad or EXCEL sheet.

Based on that i will try to send you code.

Cheers!!

0 Kudos

Hi Bala,

Thnx for your info... Basically i have notepad records with TAB delimiter.

I dont want the recording method & direct insert from internal table to z table.

Plz do the needfull.

Mohana

0 Kudos

You have to do a direct insert into the Z-table. there is no other way.

like MD said, just put the data into a internal table like your Z-table and insert the internal table to the z-table.

You don't have a transaction to fill the z-table so you can't use BDC. and if you make a transaction to use BDC then you are wasting your time. direct update program is 2 hours work.

Best Regards,

Guido

0 Kudos

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!!

P561888
Active Contributor
0 Kudos

Hi,

1. First upload data into internal table from flat file.(Use Gui_upload FM)

2. do the recording method and write te program .

Regards,

Bharani

Former Member
0 Kudos

WS_UPLOAD

Regards