Application Development and Automation 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: 
Read only

BDC

Former Member
0 Likes
472

Hi Experts,

I want to create a BDC for a Z transaction .. which Posts the material back to the Stock.

I have recorded the Fields required on the Screen and then created the Program from the recording i have done then created the internal table for the fields recorded then LOOP .. ENDLOOP......

but the problem is whenever i run this program it goes in to FOREGROUND mode ....

i want this program to be run in BACKGROUND mode....

code is as follows....

INCLUDE bdcrecx1.

TYPES: BEGIN OF ty_tab,

gate_id(4), " TYPE zsct-gate_id,

pcr_cur_matnr(18)," TYPE ztmirs-pcr_cur_matnr,

pcr_cur_batch(6), "TYPE ztmirs-pcr_cur_batch,

pcr_new_matnr(18), " TYPE ztmirs-pcr_new_matnr,

pcr_qty(5), " TYPE ztmirs-pcr_qty,

END OF ty_tab.

DATA : it_tab TYPE STANDARD TABLE OF ty_tab.

DATA : wa_tab TYPE ty_tab.

START-OF-SELECTION.

wa_tab-gate_id = p_gate_id.

wa_tab-pcr_cur_matnr = p_cur_mpn.

wa_tab-pcr_new_matnr = p_new_mpn.

wa_tab-pcr_cur_batch = p_cur_bat.

wa_tab-pcr_qty = p_qty.

append wa_tab to it_tab.

LOOP AT it_tab INTO wa_tab.

PERFORM open_group.

PERFORM bdc_dynpro USING 'ZMMX_SHOP_EXECUTION' '1000'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=PARTS'.

PERFORM bdc_dynpro USING 'ZMMX_PARTS_CHANGE' '1000'.

PERFORM bdc_field USING 'BDC_CURSOR'

'P_QTY'.

PERFORM bdc_field USING 'BDC_OKCODE'

'SPOS'.

PERFORM bdc_field USING 'P_STATIO'

wa_tab-gate_id.

PERFORM bdc_field USING 'P_CMATNR'

wa_tab-pcr_cur_matnr.

PERFORM bdc_field USING 'P_CCHARG'

wa_tab-pcr_cur_batch.

PERFORM bdc_field USING 'P_NMATNR'

wa_tab-pcr_new_matnr.

PERFORM bdc_field USING 'P_QTY'

wa_tab-pcr_qty.

PERFORM bdc_dynpro USING 'ZMMX_PARTS_CHANGE' '1000'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/EE'.

PERFORM bdc_field USING 'BDC_CURSOR'

'P_STATIO'.

PERFORM bdc_dynpro USING 'ZMMX_SHOP_EXECUTION' '1000'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/ECBAC'.

PERFORM bdc_transaction USING 'ZMMX'.

ENDLOOP.

PERFORM close_group.

regards,

Jay.

4 REPLIES 4
Read only

Former Member
0 Likes
427

In recording;

1. check the parameter's you have selected.

2. in your recording one of the indicator is not recorded (this is SAP standards). check in your process

Read only

Former Member
0 Likes
427

Use this code it will work



INCLUDE bdcrecx1.

TYPES: BEGIN OF ty_tab,
gate_id(4), " TYPE zsct-gate_id,
pcr_cur_matnr(18)," TYPE ztmirs-pcr_cur_matnr,
pcr_cur_batch(6), "TYPE ztmirs-pcr_cur_batch,
pcr_new_matnr(18), " TYPE ztmirs-pcr_new_matnr,
pcr_qty(5), " TYPE ztmirs-pcr_qty,
END OF ty_tab.

DATA : it_tab TYPE STANDARD TABLE OF ty_tab.

DATA : wa_tab TYPE ty_tab.


START-OF-SELECTION.

wa_tab-gate_id = p_gate_id.
wa_tab-pcr_cur_matnr = p_cur_mpn.
wa_tab-pcr_new_matnr = p_new_mpn.
wa_tab-pcr_cur_batch = p_cur_bat.
wa_tab-pcr_qty = p_qty.
append wa_tab to it_tab.


LOOP AT it_tab INTO wa_tab.
PERFORM open_group.

PERFORM bdc_dynpro USING 'ZMMX_SHOP_EXECUTION' '1000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=PARTS'.
PERFORM bdc_dynpro USING 'ZMMX_PARTS_CHANGE' '1000'.
PERFORM bdc_field USING 'P_STATIO'
wa_tab-gate_id.
PERFORM bdc_field USING 'P_CMATNR'
wa_tab-pcr_cur_matnr.
PERFORM bdc_field USING 'P_CCHARG'
wa_tab-pcr_cur_batch.
PERFORM bdc_field USING 'P_NMATNR'
wa_tab-pcr_new_matnr.
PERFORM bdc_field USING 'P_QTY'
wa_tab-pcr_qty.
PERFORM bdc_field USING 'BDC_OKCODE'
'SPOS'.
PERFORM bdc_dynpro USING 'ZMMX_PARTS_CHANGE' '1000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/EE'.
PERFORM bdc_dynpro USING 'ZMMX_SHOP_EXECUTION' '1000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/ECBAC'.
PERFORM bdc_transaction USING 'ZMMX'.
ENDLOOP.
PERFORM close_group.

Read only

Former Member
0 Likes
427

coz ur not selecting in background mode..

take alook at this

data : p_mode type c value 'N'

CALL TRANSACTION 'Z' USING bdcdata

MODE p_mode

UPDATE 'S'

MESSAGES INTO gt_messtab.

where N: bckground

A:foreground.

the default now is N if u wanna see it running in the foreground u can change it when debugging.

hope this helps

Read only

Former Member
0 Likes
427

hi comment this ..

you will get the screen for background or foreground because you are using the stanard include INCLUDE bdcrecx1. right..

then debugg. it .