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

Kindly let me the error in this code

Former Member
0 Likes
1,717

FORM transaction_bdc .

DATA :

v_cnt(2) TYPE n,

v_bst(2) TYPE n,

v_bn TYPE i,

v_bstpo(25),

v_ebtyp(25),

v_menge(25),

v_eeind(25),

v_xblnr(25),

v_xblnr1(25),

v_ebelp(2) TYPE n,

v_ebelpt(2),

v_menge1(11),

v_ebt TYPE i,

v_vebtyp LIKE ekes-ebtyp,

v_eb(2) TYPE n,

v_tcselflag(40),

v_tem(2) TYPE n,

v_correct TYPE i,

v_file TYPE string.

DATA: ls_outtab TYPE tb_struc.

DATA: l_valid TYPE c,

l_locked TYPE c.

CALL METHOD g_grid->check_changed_data

IMPORTING

e_valid = l_valid.

IF l_valid EQ 'X'.

LOOP AT tb_output WHERE check EQ 'X' .

MOVE-CORRESPONDING tb_output TO itab_output.

APPEND itab_output.

CLEAR itab_output.

ENDLOOP.

IF tb_output-check <> 'X'.

MESSAGE e003 WITH text-004.

ENDIF.

ENDIF.

IF itab_output[] IS NOT INITIAL.

PERFORM open_group.

***looping at purchase order level.

LOOP AT itab_output where ebelp is not initial .

*read table itab_output with key ebelp = ekpo-ebelp.

CLEAR v_bn.

CLEAR v_ebt.

PERFORM bdc_dynpro USING 'SAPMM06E' '0105'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RM06E-BSTNR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'RM06E-BSTNR'

itab_output-ebeln.

***Changing alphanumeric fields and quantity fields to character type**

*

*v_ebelp = tB_OUTPUT-ebelp.

*clear v_ebelpt.

*v_menge1 = tB_OUTPUT-menge.

*v_ebelpt = v_ebelp.

*

***End Of Changing**

*Checking for the exact number of the item**

LOOP AT itab_output where ebeln = tb_output-ebeln.

loop at tb_output.

IF tb_output-ebelp = itab_output-ebelp.

exit.

ELSE.

v_bn = v_bn + 1.

ENDIF.

endloop.

ENDLOOP.

v_bst = v_bn + 1.

*End Of Checking**

**Mapping items**

v_bst = v_bst - 1.

v_tem = v_bst.

CONCATENATE 'RM06E-BSTPO(' v_bst ')' INTO v_bstpo.

CONCATENATE 'RM06E-TCSELFLAG(' v_tem ')' INTO v_tcselflag.

PERFORM bdc_dynpro USING 'SAPMM06E' '0120'.

PERFORM bdc_field USING 'BDC_CURSOR'

v_bstpo.

PERFORM bdc_field USING 'BDC_OKCODE'

'=DETA'.

PERFORM bdc_field USING 'RM06E-EBELP'

v_ebelpt.

PERFORM bdc_dynpro USING 'SAPMM06E' '0111'.

PERFORM bdc_field USING 'BDC_CURSOR'

'EKPO-BSTAE'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_dynpro USING 'SAPMM06E' '0120'.

PERFORM bdc_field USING 'BDC_CURSOR'

v_bstpo.

PERFORM bdc_field USING 'BDC_OKCODE'

'=BSTA'.

PERFORM bdc_field USING 'RM06E-EBELP'

v_ebelpt.

PERFORM bdc_field USING v_tcselflag

'X'.

**Checking weather Confirmation category already exists**

SELECT ebtyp FROM ekes INTO v_vebtyp WHERE ebelp =

itab_output-ebelp AND ebeln = itab_output-ebeln.

ENDSELECT.

IF sy-dbcnt > 0.

v_ebt = sy-dbcnt.

ENDIF.

v_eb = v_ebt + 1.

**End Of Checking**

**For Line items**

CONCATENATE 'EKES-EBTYP(' v_eb ')' INTO v_ebtyp.

CONCATENATE 'EKES-MENGE(' v_eb ')' INTO v_menge.

CONCATENATE 'RM06E-EEIND(' v_eb ')' INTO v_eeind.

CONCATENATE 'EKES-XBLNR(' v_eb ')' INTO v_xblnr.

**End**

PERFORM bdc_dynpro USING 'SAPLEINB' '0200'.

PERFORM bdc_field USING 'BDC_CURSOR'

v_xblnr.

PERFORM bdc_field USING 'BDC_OKCODE'

'=BU'.

PERFORM bdc_field USING v_ebtyp

itab_output-ebtyp.

PERFORM bdc_field USING v_eeind

itab_output-eindt.

PERFORM bdc_field USING v_menge

v_menge1.

PERFORM bdc_field USING v_xblnr

itab_output-xblnr.

**End Of Mappings**

loop at itab_output.

MOVE-CORRESPONDING itab_output TO ekes.

modify ekes.

  • MOVE-CORRESPONDING itab_output TO eket.

  • MODIFY eket.

    • MOVE-CORRESPONDING tb_output TO ekpo.

    • MODIFY ekpo.

ENDLOOP.

CALL TRANSACTION 'ME22N'

USING itbdc

MODE 'E'.

*perform bdc_transaction using 'ME22N'.

endloop.

endif.

**End Of Purchase Order Loop**

PERFORM close_group.

FORM transaction_bdc .

DATA :

v_cnt(2) TYPE n,

v_bst(2) TYPE n,

v_bn TYPE i,

v_bstpo(25),

v_ebtyp(25),

v_menge(25),

v_eeind(25),

v_xblnr(25),

v_xblnr1(25),

v_ebelp(2) TYPE n,

v_ebelpt(2),

v_menge1(11),

v_ebt TYPE i,

v_vebtyp LIKE ekes-ebtyp,

v_eb(2) TYPE n,

v_tcselflag(40),

v_tem(2) TYPE n,

v_correct TYPE i,

v_file TYPE string.

DATA: ls_outtab TYPE tb_struc.

DATA: l_valid TYPE c,

l_locked TYPE c.

CALL METHOD g_grid->check_changed_data

IMPORTING

e_valid = l_valid.

IF l_valid EQ 'X'.

LOOP AT tb_output WHERE check EQ 'X' .

MOVE-CORRESPONDING tb_output TO itab_output.

APPEND itab_output.

CLEAR itab_output.

ENDLOOP.

IF tb_output-check <> 'X'.

MESSAGE e003 WITH text-004.

ENDIF.

ENDIF.

IF itab_output[] IS NOT INITIAL.

PERFORM open_group.

***looping at purchase order level.

LOOP AT itab_output where ebelp is not initial .

*read table itab_output with key ebelp = ekpo-ebelp.

CLEAR v_bn.

CLEAR v_ebt.

PERFORM bdc_dynpro USING 'SAPMM06E' '0105'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RM06E-BSTNR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'RM06E-BSTNR'

itab_output-ebeln.

***Changing alphanumeric fields and quantity fields to character type**

*

*v_ebelp = tB_OUTPUT-ebelp.

*clear v_ebelpt.

*v_menge1 = tB_OUTPUT-menge.

*v_ebelpt = v_ebelp.

*

***End Of Changing**

*Checking for the exact number of the item**

LOOP AT itab_output where ebeln = tb_output-ebeln.

loop at tb_output.

IF tb_output-ebelp = itab_output-ebelp.

exit.

ELSE.

v_bn = v_bn + 1.

ENDIF.

endloop.

ENDLOOP.

v_bst = v_bn + 1.

*End Of Checking**

**Mapping items**

v_bst = v_bst - 1.

v_tem = v_bst.

CONCATENATE 'RM06E-BSTPO(' v_bst ')' INTO v_bstpo.

CONCATENATE 'RM06E-TCSELFLAG(' v_tem ')' INTO v_tcselflag.

PERFORM bdc_dynpro USING 'SAPMM06E' '0120'.

PERFORM bdc_field USING 'BDC_CURSOR'

v_bstpo.

PERFORM bdc_field USING 'BDC_OKCODE'

'=DETA'.

PERFORM bdc_field USING 'RM06E-EBELP'

v_ebelpt.

PERFORM bdc_dynpro USING 'SAPMM06E' '0111'.

PERFORM bdc_field USING 'BDC_CURSOR'

'EKPO-BSTAE'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_dynpro USING 'SAPMM06E' '0120'.

PERFORM bdc_field USING 'BDC_CURSOR'

v_bstpo.

PERFORM bdc_field USING 'BDC_OKCODE'

'=BSTA'.

PERFORM bdc_field USING 'RM06E-EBELP'

v_ebelpt.

PERFORM bdc_field USING v_tcselflag

'X'.

**Checking weather Confirmation category already exists**

SELECT ebtyp FROM ekes INTO v_vebtyp WHERE ebelp =

itab_output-ebelp AND ebeln = itab_output-ebeln.

ENDSELECT.

IF sy-dbcnt > 0.

v_ebt = sy-dbcnt.

ENDIF.

v_eb = v_ebt + 1.

**End Of Checking**

**For Line items**

CONCATENATE 'EKES-EBTYP(' v_eb ')' INTO v_ebtyp.

CONCATENATE 'EKES-MENGE(' v_eb ')' INTO v_menge.

CONCATENATE 'RM06E-EEIND(' v_eb ')' INTO v_eeind.

CONCATENATE 'EKES-XBLNR(' v_eb ')' INTO v_xblnr.

**End**

PERFORM bdc_dynpro USING 'SAPLEINB' '0200'.

PERFORM bdc_field USING 'BDC_CURSOR'

v_xblnr.

PERFORM bdc_field USING 'BDC_OKCODE'

'=BU'.

PERFORM bdc_field USING v_ebtyp

itab_output-ebtyp.

PERFORM bdc_field USING v_eeind

itab_output-eindt.

PERFORM bdc_field USING v_menge

v_menge1.

PERFORM bdc_field USING v_xblnr

itab_output-xblnr.

**End Of Mappings**

loop at itab_output.

MOVE-CORRESPONDING itab_output TO ekes.

modify ekes.

  • MOVE-CORRESPONDING itab_output TO eket.

  • MODIFY eket.

    • MOVE-CORRESPONDING tb_output TO ekpo.

    • MODIFY ekpo.

ENDLOOP.

CALL TRANSACTION 'ME22N'

USING itbdc

MODE 'E'.

*perform bdc_transaction using 'ME22N'.

endloop.

endif.

**End Of Purchase Order Loop**

PERFORM close_group.

15 REPLIES 15
Read only

Former Member
0 Likes
1,638

What is the nature of the problem? Syntax error, short dump, incorrect results?

Rob

Read only

0 Likes
1,638

I am getting only one line item for a PO whereas I want all line items

Read only

Former Member
0 Likes
1,638

hi asha..

after checking the syntax error for the code you give given..

it sayserror in this line. <b>DATA: ls_outtab TYPE tb_struc</b>.

that is , the type "tb_struc" is unknown.

so please check this declaration.

hope this helps you..

reward if useful..

Read only

Former Member
0 Likes
1,638

I think you have to record me22n for multiple line items( in table control multiple entries should be entered)..

let me know if this doesn't work..

Regards,

Srini

Read only

0 Likes
1,638

How to define a table control for this . Can you help me

Read only

Former Member
0 Likes
1,638

Hi Asha ,

Try executing the transaction in mode 'A' , so insted of

CALL TRANSACTION 'ME22N'

USING itbdc

MODE 'E'.

use

CALL TRANSACTION 'ME22N'

USING itbdc

MODE 'A'.

and see what is the message/error which occurs when the BDC tried to fill the second line item.

Regards

Arun

Read only

0 Likes
1,638

Used mode A but got the same result only one item also no error /message

Read only

0 Likes
1,638

Hi Asha ,

Is the BDC called for the second record , what happens when the second record is used , what i mean is that you have entered the 2nd record details in the internal table , as u can see in mode 'A' it goes step by step , once the fileds for first line is filled , then the 2nd line must be porcessed , what happnens at that time .Is there any attempt to populate the field in the screen or not.

Regards

Arun

Read only

0 Likes
1,638

The problem now is the data for single line item is getting updated and as soon as the call transaction method is encountered the prog. goes to ME22N n hence the loop is not completed . the second line item is not updated.

Read only

0 Likes
1,638

Hi Asha ,

Try placing the statement

CALL TRANSACTION 'ME22N'

USING itbdc

MODE 'E'.

after the <b>endloop.</b>

Try this and please tell me what is the result , first try running this in mode 'A'.

Regards

Arun

Read only

0 Likes
1,638

Placed call transaction outside loop with both A and E but same result

Read only

0 Likes
1,638

Hi ,

Is it still the same case that before the second line item is filled the transaction is called , if that is the case please confirm whether the details of line item 2 are filled in the internal table used for BDC.

Regards

Arun

Read only

0 Likes
1,638

the internal table is getting filled

Read only

Former Member
0 Likes
1,638

Hi Asha,

Place the call transaction in the loop and check once.

reward points if it is helpdul

Reagrds,

Kiran i

Read only

0 Likes
1,638

Already done