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: 

BDCDATA for include ZXVEDU04 of EXIT_SAPLVEDA_002?

Former Member
0 Kudos

I am attempting to write my first user exit for an Inbound IDoc. Outbound seems easy by comparison. I am going to add a date to VBAK-MAHDT from an extended ORDERS03 segment. The new IDoc type is called 'Z_EK_ORDERS03' and my extended segment is pretty much like E1EDK03.

I'm working with enhancement VEDA0001. For include ZXVEDU03 of component EXIT_SAPLVEDA_001 I have this so far:

DATA:

w_z1edk03 LIKE z1edk03,

w_vbak LIKE vbak.

IF contrl-mestyp = 'ORDERS' AND

contrl-idoctp = 'Z_EK_ORDERS03'.

CASE segment-segnam.

WHEN 'Z1EDK03'.

IF segment-sdata(3) = 'Z01'.

w_z1edk03 = segment-sdata.

MOVE dxvbak TO w_vbak.

w_vbak-mahdt = w_z1edk03-datum.

MOVE w_vbak TO dxvbak.

ENDIF.

WHEN OTHERS.

ENDCASE.

ENDIF.

Now I need to insert the date into the right screen using include ZXVEDU04 of EXIT_SAPLVEDA_002. I have this so far:

DATA:

x_bdc LIKE bdcdata OCCURS 0,

w_vbak LIKE vbak,

w_bdc TYPE bdcdata,

i_bdc TYPE I.

MOVE dxbdcdata TO w_bdc.

IF w_bdc-fnam EQ SPACE.

i_bdc = sy-tabix - 1.

READ TABLE dxbdcdata INDEX i_bdc.

MOVE dxbdcdata TO w_bdc.

ENDIF.

IF w_bdc-fnam = 'BDC_OKCODE' AND

w_bdc-fval = 'SICH'.

CLEAR w_bdc.

LOOP AT dxbdcdata INTO w_bdc.

APPEND w_bdc TO x_bdc.

CASE w_bdc-fnam.

WHEN 'VBKD-BSTKD'.

MOVE dxvbak TO w_vbak.

IF NOT w_vbak-mahdt IS INITIAL.

w_bdc-fnam = 'VBAK-MAHDT'.

w_bdc-fval = w_vbak-mahdt.

APPEND w_bdc TO x_bdc.

ENDIF.

WHEN OTHERS.

ENDCASE.

ENDLOOP.

dxbdcdata[] = x_bdc[].

ENDIF.

This gives me an error of 'VBAK-MAHDT does not exist for screen 4001'. Do I have to add BDC records for screen '4351'? If I do what would the OPCODE be? Is there an easier way to accomplish my goals rather than using BDC at all?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

You have to add your line in BDCDATA on screen 4002.

But screen 4002 will have multiple ocurances .

The correct one is the one which follows OK_CODE "UER2".

Try this it should work .

DATA:

X_BDC LIKE BDCDATA OCCURS 0,

W_VBAK LIKE VBAK,

W_BDC TYPE BDCDATA,

N_BDC TYPE BDCDATA,

FLAG TYPE C.

MOVE DXBDCDATA TO W_BDC.

IF W_BDC-FNAM = 'BDC_OKCODE' AND W_BDC-FVAL = 'SICH'.

CLEAR W_BDC.

MOVE DXVBAK TO W_VBAK.

IF NOT W_VBAK-MAHDT IS INITIAL.

LOOP AT DXBDCDATA INTO W_BDC.

APPEND W_BDC TO X_BDC.

IF FLAG EQ 'X'.

IF W_BDC-DYNPRO = 4002 .

CLEAR N_BDC.

N_BDC-FNAM = 'VBAK-MAHDT'.

N_BDC-FVAL = W_VBAK-MAHDT.

APPEND N_BDC TO X_BDC.

ENDIF.

ENDIF.

IF W_BDC-FNAM = 'BDC_OKCODE' AND W_BDC-FVAL = 'UER2',

FLAG = 'X'.

ELSE.

FLAG = ' '.

ENDIF. .

ENDLOOP.

REFRESH DXBDCDATA .

DXBDCDATA[] = X_BDC[].

ENDIF.

ENDIF.

If this does not work then put a break point on Call Transcation in IDOC_INPUT_ORDERS. At runtime analyze the data in BDCDATA and see where you have to put your line.

You can change BDC_MODE from "N" to "A" here and execute the transaction and you can see the exact flow of how a sales order is created . This will help you in building the logic of putting your line in BDCDATA. Its just that you have to put it on the correct screen.

Cheers.

3 REPLIES 3

Former Member
0 Kudos

Hi,

The OkCODE would be 'KBES' and you have to add BDC records for the screen 'Purchase order data' in screen number 4351.

Former Member
0 Kudos

OK, I've tried inseting this in various positions of the BDCDATA table but it is not working. With this latest code I get 'No batch input data for screen SAPMV45A 4002' error.

DATA:

x_bdc LIKE bdcdata OCCURS 0,

w_vbak LIKE vbak,

w_bdc TYPE bdcdata,

n_bdc TYPE bdcdata,

i_bdc TYPE I,

done TYPE C.

MOVE dxbdcdata TO w_bdc.

IF w_bdc-fnam EQ SPACE.

i_bdc = sy-tabix - 1.

READ TABLE dxbdcdata INDEX i_bdc.

MOVE dxbdcdata TO w_bdc.

ENDIF.

IF w_bdc-fnam = 'BDC_OKCODE' AND

w_bdc-fval = 'SICH'.

CLEAR w_bdc.

LOOP AT dxbdcdata INTO w_bdc.

APPEND w_bdc TO x_bdc.

IF w_bdc-fval = 'KPAR_SUB' AND done IS INITIAL.

MOVE dxvbak TO w_vbak.

IF NOT w_vbak-mahdt IS INITIAL.

n_bdc-program = 'SAPMV45A'.

n_bdc-dynpro = 4351.

n_bdc-dynbegin = 'X'.

APPEND n_bdc TO x_bdc.

CLEAR n_bdc.

n_bdc-fnam = 'VBAK-MAHDT'.

n_bdc-fval = w_vbak-mahdt.

APPEND n_bdc TO x_bdc.

CLEAR n_bdc.

n_bdc-fnam = 'BDC_OKCODE'.

n_bdc-fval = 'KBES'.

APPEND n_bdc TO x_bdc.

CLEAR n_bdc.

ENDIF.

done = 'X'.

ENDIF.

ENDLOOP.

dxbdcdata[] = x_bdc[].

ENDIF.

Does anyone have an example of hopw this is supposed to work?

Former Member
0 Kudos

You have to add your line in BDCDATA on screen 4002.

But screen 4002 will have multiple ocurances .

The correct one is the one which follows OK_CODE "UER2".

Try this it should work .

DATA:

X_BDC LIKE BDCDATA OCCURS 0,

W_VBAK LIKE VBAK,

W_BDC TYPE BDCDATA,

N_BDC TYPE BDCDATA,

FLAG TYPE C.

MOVE DXBDCDATA TO W_BDC.

IF W_BDC-FNAM = 'BDC_OKCODE' AND W_BDC-FVAL = 'SICH'.

CLEAR W_BDC.

MOVE DXVBAK TO W_VBAK.

IF NOT W_VBAK-MAHDT IS INITIAL.

LOOP AT DXBDCDATA INTO W_BDC.

APPEND W_BDC TO X_BDC.

IF FLAG EQ 'X'.

IF W_BDC-DYNPRO = 4002 .

CLEAR N_BDC.

N_BDC-FNAM = 'VBAK-MAHDT'.

N_BDC-FVAL = W_VBAK-MAHDT.

APPEND N_BDC TO X_BDC.

ENDIF.

ENDIF.

IF W_BDC-FNAM = 'BDC_OKCODE' AND W_BDC-FVAL = 'UER2',

FLAG = 'X'.

ELSE.

FLAG = ' '.

ENDIF. .

ENDLOOP.

REFRESH DXBDCDATA .

DXBDCDATA[] = X_BDC[].

ENDIF.

ENDIF.

If this does not work then put a break point on Call Transcation in IDOC_INPUT_ORDERS. At runtime analyze the data in BDCDATA and see where you have to put your line.

You can change BDC_MODE from "N" to "A" here and execute the transaction and you can see the exact flow of how a sales order is created . This will help you in building the logic of putting your line in BDCDATA. Its just that you have to put it on the correct screen.

Cheers.