Skip to Content
0
Jun 05, 2008 at 08:00 AM

Simple BDC issue (Please help, its urgent)

27 Views

Hi Experts,

I am working on a BDC which is almost complete but one issue I am facing is that its not picking the subsequent document numbers. Example:

BDC is picking the first document nubmer 1000000158 and filling all the fields properly but not shifting to the next document nubmer which is 1000000159.

My file format is .

Document No Date S.N Material No. Qty ZC

___________ ____ ___ _________ ___ ___

100000158 05.06.2008 001 20002545 1

100000158 05.06.2008 002 20002359 X

100000159 05.06.2008 001 20002357 1

100000159 05.06.2008 002 20002072 X

Here I have two internal tables:

1) Header

2) Item

First doucment nubmer (1000000158) and its date comes on the first screen takin' data from header table and after entering it goes to to the next screen takes data from the Item table.

Here for the first document nubmer which is (100000158 ) processings goes very well but after its completion not moving for the subscequent document numbers.

I am looping like that:

Loop at header.

*

*

Loop at item where iblnr = header-iblnr.

*

*

*

Endloop.

Endloop.

Please help as soon as possible.

For reference I am pasting the code which I have prepared.

LOOP AT header.

cnt = sy-tabix.

PERFORM bdc_dynpro USING 'SAPMM07I' '0701'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RM07I-IBLNR'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'RM07I-IBLNR'

header-iblnr.

PERFORM bdc_field USING 'RM07I-GJAHR'

header-gjahr.

PERFORM bdc_field USING 'RM07I-ZLDAT'

header-date.

DATA : fnam(20) TYPE c,

idx(3) TYPE n VALUE 1,

lv_lines(6) TYPE n,

lv_pages TYPE i,

lv_pages1 TYPE i,

lv_lstcur TYPE i,

lv_lstcur1 TYPE i,

temp TYPE i,

lv_poscur TYPE i,

lv_pagecnt TYPE i,

lv_onelesspage TYPE i,

cnt_x TYPE i,

count TYPE i,

count1 TYPE i.

DATA: val TYPE i,

val1 TYPE i.

DATA: flag(15) TYPE c.

DATA: flag1 TYPE i VALUE 1.

DATA: local_count TYPE i VALUE 8.

DATA: lv_one(8) TYPE c.

idx = 1.

SELECT * FROM iseg INTO TABLE it_iseg WHERE iblnr = header-iblnr

AND gjahr = header-gjahr.

DESCRIBE TABLE it_iseg LINES lv_lines.

COMPUTE lv_lstcur = lv_lines mod 8.

temp = lv_lstcur.

lv_lstcur = lv_lstcur + 1.

COMPUTE lv_pages = lv_lines div 8.

COMPUTE lv_poscur = 8 - lv_lstcur.

  • Determining the LAST PAGE

COMPUTE lv_lstcur1 = temp mod 2.

IF lv_lstcur1 = 0.

  • do nothing

ELSE.

lv_pages = lv_pages + 1.

ENDIF.

lv_onelesspage = lv_pages - 1.

cnt_x = 1.

IF lv_pages = 1.

lv_one = 'ONE_PAGE'.

ENDIF.

  • Process ITEM

LOOP AT item WHERE iblnr = header-iblnr

AND gjahr = header-gjahr.

IF lv_one <> 'ONE_PAGE'.

IF local_count = 0.

lv_pagecnt = lv_pagecnt + 1.

PERFORM bdc_dynpro USING 'SAPMM07I' '0731'.

PERFORM bdc_field USING 'BDC_CURSOR'

'ISEG-ERFMG(06)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=P+'.

local_count = 8.

cnt_x = cnt_x + 1.

IF lv_pagecnt = lv_pages.

lv_poscur = lv_poscur + 1.

MOVE lv_poscur TO idx.

ELSE.

MOVE 1 TO idx.

ENDIF.

ENDIF.

  • Last Page calculation, if loop reached to the last page.

IF lv_pagecnt = lv_onelesspage.

IF flag1 = 1.

flag = 'LAST_PAGE'.

COMPUTE val = lv_lines mod 8.

val1 = 8 - val.

lv_poscur = idx + val1.

MOVE lv_poscur TO idx.

ENDIF.

*Flag1 set to 2 because the last page is reached and can not go further.

flag1 = 2.

IF flag = 'LAST_PAGE'.

CONCATENATE 'ISEG-ERFMG(' idx ')' INTO fnam.

PERFORM bdc_dynpro USING 'SAPMM07I' '0731'.

PERFORM bdc_field USING 'BDC_CURSOR'

fnam.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING fnam

item-qty.

CONCATENATE 'ISEG-XNULL(' idx ')' INTO fnam.

IF item-zc = 'X'.

PERFORM bdc_field USING fnam

item-zc.

ENDIF.

idx = idx + 1.

ENDIF.

ENDIF.

  • Continous if LAST PAGE is not reached.

IF flag NE 'LAST_PAGE'.

CONCATENATE 'ISEG-ERFMG(' idx ')' INTO fnam.

PERFORM bdc_dynpro USING 'SAPMM07I' '0731'.

PERFORM bdc_field USING 'BDC_CURSOR'

fnam.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING fnam

item-qty.

CONCATENATE 'ISEG-XNULL(' idx ')' INTO fnam.

IF item-zc = 'X'.

PERFORM bdc_field USING fnam

item-zc.

ENDIF.

idx = idx + 1.

ENDIF.

local_count = local_count - 1.

ELSE.

PERFORM bdc_dynpro USING 'SAPMM07I' '0731'.

PERFORM bdc_field USING 'BDC_CURSOR'

'ISEG-ERFMG'.

CONCATENATE 'ISEG-ERFMG(' idx ')' INTO fnam.

PERFORM bdc_dynpro USING 'SAPMM07I' '0731'.

PERFORM bdc_field USING 'BDC_CURSOR'

fnam.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING fnam

item-qty.

CONCATENATE 'ISEG-XNULL(' idx ')' INTO fnam.

IF item-zc = 'X'.

PERFORM bdc_field USING fnam

item-zc.

ENDIF.

idx = idx + 1.

ENDIF.

ENDLOOP.

CONTINUE.

  • PERFORM bdc_field USING 'BDC_OKCODE'

*'=BU'.

CLEAR: lv_one,

flag.

ENDLOOP.

PERFORM bdc_field USING 'BDC_OKCODE'

'=BU'.

CALL TRANSACTION 'MI04' USING ibdc

MODE 'A' UPDATE 'S'

MESSAGES INTO msgtab.