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: 

Call to BDC program.

Former Member
0 Kudos

Hello,

I have one program let say XYZ through which i want to call other BDC program by passing internal table of XYZ program to BDC program.

Can any one have sample code or any idea about this problem.

Reagrds,

Amey

1 ACCEPTED SOLUTION

abdul_hakim
Active Contributor
0 Kudos

Hi

Use SUBMIT statement to call the program.Before the call use EXPORT statement to export your internal table to ABAP Memory and then use IMPORT statement to import the internal table in the 2nd BDC Program.

Hope this will solve.

Regards,

Abdul

7 REPLIES 7

furlan
Participant
0 Kudos

Amey,

Once you have BDC mapped (use transaction SHDB), you can base your code in the folloing example:

.......

PERFORM iyr_dynpro_bdc USING 'SAPMKAUF'(008) '0110'(009).

PERFORM iyr_campo_bdc USING 'BDC_CURSOR'(010) 'COAS-AUFNR'(011).

PERFORM iyr_campo_bdc USING 'BDC_OKCODE'(012) '/00'(013).

PERFORM iyr_campo_bdc USING 'COAS-AUFNR'(011) wa_tpb020aufk-aufnr.

PERFORM iyr_dynpro_bdc USING 'SAPMKAUF'(008) '0600'(014).

PERFORM iyr_campo_bdc USING 'BDC_CURSOR'(010) 'COAS-KTEXT'(015).

PERFORM iyr_campo_bdc USING 'BDC_OKCODE'(012) '=LSET'(016).

PERFORM iyr_campo_bdc USING 'COAS-BUKRS'(017) 'PBR'(018).

PERFORM iyr_dynpro_bdc USING 'SAPMKAUF'(008) '0600'(014).

PERFORM iyr_campo_bdc USING 'BDC_CURSOR'(010) 'COAS-KTEXT'(015).

PERFORM iyr_campo_bdc USING 'BDC_OKCODE'(012) '=SICH'(019).

REFRESH it_bdc_msgcoll.

CALL TRANSACTION 'KO02' USING it_bdc_data

MODE 'A'(020) UPDATE 'S'(021)

MESSAGES INTO it_bdc_msgcoll.

*************************************************

  • Forms

*************************************************

FORM iyr_dynpro_bdc USING iyl_bdc_program_x TYPE c

iyl_bdc_dynpro_x TYPE c.

CLEAR wa_it_bdc_data.

wa_it_bdc_data-program = iyl_bdc_program_x.

wa_it_bdc_data-dynpro = iyl_bdc_dynpro_x.

wa_it_bdc_data-dynbegin = 'X'(038).

APPEND wa_it_bdc_data TO it_bdc_data.

ENDFORM. " IYR_DYNPRO_BDC

FORM iyr_campo_bdc USING value(iyl_fnam_x) TYPE c

value(iyl_fval_x) TYPE any.

CLEAR wa_it_bdc_data.

wa_it_bdc_data-fnam = iyl_fnam_x.

wa_it_bdc_data-fval = iyl_fval_x.

APPEND wa_it_bdc_data TO it_bdc_data.

ENDFORM. " IYR_CAMPO_BDC

.....

This is only an clue to you I hope this help you!

Flávio Furlan

abdul_hakim
Active Contributor
0 Kudos

Hi

Use SUBMIT statement to call the program.Before the call use EXPORT statement to export your internal table to ABAP Memory and then use IMPORT statement to import the internal table in the 2nd BDC Program.

Hope this will solve.

Regards,

Abdul

Former Member
0 Kudos

Hi Amey,

Firstly Your BDC program should be written in such a way that it can be called by passing an internal table.

Then you can call that program like (For eg:)

SUBMIT zacc_jv_postings

WITH inv_file = in_file

WITH out_file = oute_file

WITH ccode = ccode

WITH dtype = dtype

WITH period = period

WITH postdate = postdate

WITH p_group = v_group

WITH p_user = p_user

WITH group = group

WITH user = user

WITH keep = keep

WITH holddate = holddate

AND RETURN.

Regards,

Raj

Former Member
0 Kudos

Declare the internal table in a common part of both programs. The contents will then be known to the submitted program. From F1 on 'common':


DATA: BEGIN OF COMMON PART c,   
      END   OF COMMON PART. 

Rob

Former Member
0 Kudos

Pls use submit.

SUBMIT REPORT01

VIA SELECTION-SCREEN

USING SELECTION-SET 'VARIANT1'

AND RETURN.

Befor this just export yuour internal table to the memory .

Then import in your bdc progrm

Former Member
0 Kudos

Hi Amey,

For this you gotta use the submit statement. Keep in mind the way the submit program is to be called, i.e., via selection screen or via job(background). Following is how you have to use the submit statement:

SUBMIT <BDC Program>

TO SAP-SPOOL

IMMEDIATELY ' ' DESTINATION '' KEEP IN SPOOL 'X'

WITHOUT SPOOL DYNPRO

USER sy-uname VIA JOB <JOB NAME> NUMBER <JOB NUMBER>

WITH <SELECT-OPTIONS ON BDC Program Selection Screen> IN <INTERNAL TABLE>

AND RETURN.

In this way you can call the BDC program and come back to your calling program and do further processing.

If you do not want to submit the job, the following lines can be removed from the above code extract:

TO SAP-SPOOL

IMMEDIATELY ' ' DESTINATION '' KEEP IN SPOOL 'X'

WITHOUT SPOOL DYNPRO

USER sy-uname VIA JOB <JOB NAME> NUMBER <JOB NUMBER>

Cheers,

Naveen.