‎2006 Mar 24 3:18 PM
Hi Friends,
I am working on creating Credit memos and return orders through BDC. For the item level, I am incrementing the index in order to enter the MATNR, POSNR, KWMENG etc. I have seven lines open in my screen. So when I have an order greater than or equal to seven lines, the program is showing an error that that line does not exist in the screen. Please, let me know what is the solution for this.
Thanks,
Raj
‎2006 Mar 24 4:49 PM
Hi, as Srinivas post before that should work, I just edited some lines, I guess was just mistyped.
idx = 01.
LOOP AT itabi WHERE ihrez = itabh-ihrez.
PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=POAN'.
CONCATENATE 'VBAP-ABGRU(' idx ')' INTO fnam.
PERFORM bdc_field USING 'BDC_CURSOR' fnam.
CONCATENATE 'RV45A-MABNR(' idx ')' INTO fnam.
PERFORM bdc_field USING fnam itabi-mabnr.
CONCATENATE 'VBAP-ZMENG(' idx ')' INTO fnam.
PERFORM bdc_field USING fnam itabi-zmeng.
CONCATENATE 'VBAP-POSNR(' idx ')' INTO fnam.
PERFORM bdc_field USING fnam itabi-posnr.
CONCATENATE 'VBAP-ABGRU(' idx ')' INTO fnam.
PERFORM bdc_field USING fnam 'Z2'.
PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=PKO1'.
CONCATENATE 'VBAP-POSNR(' idx ')' INTO fnam.
PERFORM bdc_field USING 'BDC_CURSOR' fnam.
PERFORM bdc_dynpro USING 'SAPMV45A' '5003'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
PERFORM bdc_field USING 'BDC_CURSOR' 'KOMV-KSCHL(01)'.
PERFORM bdc_dynpro USING 'SAPMV45A' '5003'.
PERFORM bdc_field USING 'BDC_OKCODE' '=V69A_KOAN'.
PERFORM bdc_field USING 'BDC_CURSOR' 'KOMV-KSCHL(01)'.
PERFORM bdc_dynpro USING 'SAPMV45A' '5003'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
PERFORM bdc_field USING 'BDC_CURSOR' 'KOMV-KWERT(07)'.
PERFORM bdc_field USING 'KOMV-KSCHL(02)' 'ZPR0'.
PERFORM bdc_field USING 'KOMV-KBETR(02)' itabi-kbetr1.
PERFORM bdc_field USING 'KOMV-KSCHL(03)' 'ZPRS'.
PERFORM bdc_field USING 'KOMV-KBETR(03)' itabi-kbetr2.
PERFORM bdc_field USING 'KOMV-KSCHL(04)' 'ZR1'.
PERFORM bdc_field USING 'KOMV-KWERT(04)' itabi-kwert1.
PERFORM bdc_field USING 'KOMV-KSCHL(05)' 'ZLWR'.
PERFORM bdc_field USING 'KOMV-KWERT(05)' itabi-kwert2.
PERFORM bdc_field USING 'KOMV-KSCHL(06)' 'ZLDL'.
PERFORM bdc_field USING 'KOMV-KWERT(06)' itabi-kwert3.
PERFORM bdc_field USING 'KOMV-KSCHL(07)' 'ZLFB'.
PERFORM bdc_field USING 'KOMV-KWERT(07)' itabi-kwert4.
perform bdc_field using 'KOMV-KSCHL(08)'
'ZLBD'.
perform bdc_field using 'KOMV-KWERT(08)'
'0.00'.
PERFORM bdc_dynpro USING 'SAPMV45A' '5003'.
PERFORM bdc_field USING 'BDC_OKCODE' '=T\13'.
PERFORM bdc_dynpro USING 'SAPMV45A' '4003'.
PERFORM bdc_field USING 'BDC_OKCODE' '/EBACK'.
PERFORM bdc_field USING 'BDC_CURSOR' 'VBAP-ZZRFAR'.
PERFORM bdc_field USING 'VBAP-ZZRWAR' itabi-wcd.
PERFORM bdc_field USING 'VBAP-ZZRFAR' itabi-fcd.
<b>IF idx >= 2.</b>
*-- from third line onwards start doing '+'
PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=POAN'.
<b>idx = 1.</b>
ELSE.
*-- this will increment it to 2 and then the IF will takeover
idx = idx + 1.
ENDIF.
ENDLOOP.
PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.
PERFORM bdc_field USING 'BDC_OKCODE''=SICH'.
Another way to do this is, usually the way I go, is to just execute the next two lines for every incoming line:
PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=POAN'.
Hope it Helps.
Regards,
Gilberto Li
‎2006 Mar 24 3:23 PM
I believe that when you get to that point, you will need to fire a page down in the OKCODE. I think maybe P+ may work. I have seen many posts that cover this. I usually try to stay away from doing this kind of thing with table controls in BDC, are you sure there is not a BAPI or function module that will work for you?
Regard,
Rich Heilman
‎2006 Mar 24 3:27 PM
Rich,
You are right. I was trying the same thing too. I saw a + sign at the bottom of the table control. I am testing through that logic, I hope that works out fine.
Thanks,
Raj
‎2006 Mar 24 3:31 PM
Yep, you probably need to keep track of what line number that you are currently on, and when at a certain index 7, 14, 21, 28 etc, hit the page down icon in your BDC. Please make sure to read the post that I have presented above, it talks about screen resolution.
<i>3. Screen Size: Make CTU_PARAMS-DEFSIZ = 'X' in your BDC.</i>
which means that this may act differently depending on what box you run it on.
So when calling the transaction make sure that you check to use the def size.
report zrich_0001 .
data: opt type CTU_PARAMS.
data: bdcdata type table of bdcdata with header line.
<b>opt-defsize = 'X'.</b>
call transaction 'VA02' using bdcdata
<b> options from opt.</b>
Regards,
Rich Heilman
‎2006 Mar 24 3:38 PM
Typically when you have such a feature(+ button), you can press that after entering every line and by doing that, you will get the new line always in either first or second position in the table control.
1. Enter the first line.
2. Enter the second line.
3. Press '+'.
4. Enter the third record in the second(or first depending on how the '+' reacts) position.
5. Repeat 3 and 4 until all the records are exhausted.
‎2006 Mar 24 3:56 PM
Srinivas,
I am giving a new line from the very first line. It is working fine till the seventh line. But after the seventh line, the cursor is coming to the MATNR position and the proghram errors there. I am also attaching my code. If you can correct me from that, it would be helpful.
idx = 01.
LOOP AT ITABI WHERE IHREZ = ITABH-IHREZ.
perform bdc_dynpro using 'SAPMV45A' '4001'.
perform bdc_field using 'BDC_OKCODE'
'=POAN'.
CONCATENATE 'VBAP-ABGRU(' IDX ')' into FNAM.
perform bdc_field using 'BDC_CURSOR'
FNAM.
CONCATENATE 'RV45A-MABNR(' IDX ')' INTO FNAM.
perform bdc_field using fnam
ITABI-MABNR.
CONCATENATE 'VBAP-ZMENG(' IDX ')' INTO FNAM.
perform bdc_field using FNAM
ITABI-ZMENG.
CONCATENATE 'VBAP-POSNR(' IDX ')' INTO FNAM.
perform bdc_field using fnam
ITABI-POSNR.
concatenate 'VBAP-ABGRU(' IDX ')' INTO FNAM.
perform bdc_field using FNAM
'Z2'.
perform bdc_dynpro using 'SAPMV45A' '4001'.
perform bdc_field using 'BDC_OKCODE'
'=PKO1'.
CONCATENATE 'VBAP-POSNR(' IDX ')' into FNAM.
perform bdc_field using 'BDC_CURSOR'
FNAM.
perform bdc_dynpro using 'SAPMV45A' '5003'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'KOMV-KSCHL(01)'.
perform bdc_dynpro using 'SAPMV45A' '5003'.
perform bdc_field using 'BDC_OKCODE'
'=V69A_KOAN'.
perform bdc_field using 'BDC_CURSOR'
'KOMV-KSCHL(01)'.
perform bdc_dynpro using 'SAPMV45A' '5003'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'KOMV-KWERT(07)'.
perform bdc_field using 'KOMV-KSCHL(02)'
'ZPR0'.
perform bdc_field using 'KOMV-KBETR(02)'
ITABI-KBETR1.
perform bdc_field using 'KOMV-KSCHL(03)'
'ZPRS'.
perform bdc_field using 'KOMV-KBETR(03)'
ITABI-KBETR2.
perform bdc_field using 'KOMV-KSCHL(04)'
'ZR1'.
perform bdc_field using 'KOMV-KWERT(04)'
ITABI-KWERT1.
perform bdc_field using 'KOMV-KSCHL(05)'
'ZLWR'.
perform bdc_field using 'KOMV-KWERT(05)'
ITABI-KWERT2.
perform bdc_field using 'KOMV-KSCHL(06)'
'ZLDL'.
perform bdc_field using 'KOMV-KWERT(06)'
ITABI-KWERT3.
perform bdc_field using 'KOMV-KSCHL(07)'
'ZLFB'.
perform bdc_field using 'KOMV-KWERT(07)'
ITABI-KWERT4.
perform bdc_field using 'KOMV-KSCHL(08)'
'ZLBD'.
perform bdc_field using 'KOMV-KWERT(08)'
'0.00'.
perform bdc_dynpro using 'SAPMV45A' '5003'.
perform bdc_field using 'BDC_OKCODE'
'=T\13'.
perform bdc_dynpro using 'SAPMV45A' '4003'.
perform bdc_field using 'BDC_OKCODE'
'/EBACK'.
perform bdc_field using 'BDC_CURSOR'
'VBAP-ZZRFAR'.
perform bdc_field using 'VBAP-ZZRWAR'
ITABI-WCD.
perform bdc_field using 'VBAP-ZZRFAR'
ITABI-FCD.
idx = IDX + 1.
ENDLOOP.
perform bdc_dynpro using 'SAPMV45A' '4001'.
perform bdc_field using 'BDC_OKCODE'
'=SICH'.
Thanks,
Raj
‎2006 Mar 24 4:16 PM
‎2006 Mar 24 4:24 PM
‎2006 Mar 24 4:30 PM
When you are creating it online, enter two lines of data and then press this button. See where the new line comes to. Is the second line a new line or is it the first line itself?
‎2006 Mar 24 4:32 PM
It is the first line that is new line.I started from the first line because we dont exactly know how many lines are coming in.
‎2006 Mar 24 4:37 PM
If it is the 2nd line, something like this should work.
idx = 01.
LOOP AT itabi WHERE ihrez = itabh-ihrez.
PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.
<b>* PERFORM bdc_field USING 'BDC_OKCODE' '=POAN'.</b>
CONCATENATE 'VBAP-ABGRU(' idx ')' INTO fnam.
PERFORM bdc_field USING 'BDC_CURSOR' fnam.
CONCATENATE 'RV45A-MABNR(' idx ')' INTO fnam.
PERFORM bdc_field USING fnam itabi-mabnr.
CONCATENATE 'VBAP-ZMENG(' idx ')' INTO fnam.
PERFORM bdc_field USING fnam itabi-zmeng.
CONCATENATE 'VBAP-POSNR(' idx ')' INTO fnam.
PERFORM bdc_field USING fnam itabi-posnr.
CONCATENATE 'VBAP-ABGRU(' idx ')' INTO fnam.
PERFORM bdc_field USING fnam 'Z2'.
PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=PKO1'.
CONCATENATE 'VBAP-POSNR(' idx ')' INTO fnam.
PERFORM bdc_field USING 'BDC_CURSOR' fnam.
PERFORM bdc_dynpro USING 'SAPMV45A' '5003'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
PERFORM bdc_field USING 'BDC_CURSOR' 'KOMV-KSCHL(01)'.
PERFORM bdc_dynpro USING 'SAPMV45A' '5003'.
PERFORM bdc_field USING 'BDC_OKCODE' '=V69A_KOAN'.
PERFORM bdc_field USING 'BDC_CURSOR' 'KOMV-KSCHL(01)'.
PERFORM bdc_dynpro USING 'SAPMV45A' '5003'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
PERFORM bdc_field USING 'BDC_CURSOR' 'KOMV-KWERT(07)'.
PERFORM bdc_field USING 'KOMV-KSCHL(02)' 'ZPR0'.
PERFORM bdc_field USING 'KOMV-KBETR(02)' itabi-kbetr1.
PERFORM bdc_field USING 'KOMV-KSCHL(03)' 'ZPRS'.
PERFORM bdc_field USING 'KOMV-KBETR(03)' itabi-kbetr2.
PERFORM bdc_field USING 'KOMV-KSCHL(04)' 'ZR1'.
PERFORM bdc_field USING 'KOMV-KWERT(04)' itabi-kwert1.
PERFORM bdc_field USING 'KOMV-KSCHL(05)' 'ZLWR'.
PERFORM bdc_field USING 'KOMV-KWERT(05)' itabi-kwert2.
PERFORM bdc_field USING 'KOMV-KSCHL(06)' 'ZLDL'.
PERFORM bdc_field USING 'KOMV-KWERT(06)' itabi-kwert3.
PERFORM bdc_field USING 'KOMV-KSCHL(07)' 'ZLFB'.
PERFORM bdc_field USING 'KOMV-KWERT(07)' itabi-kwert4.
* perform bdc_field using 'KOMV-KSCHL(08)'
* 'ZLBD'.
* perform bdc_field using 'KOMV-KWERT(08)'
* '0.00'.
PERFORM bdc_dynpro USING 'SAPMV45A' '5003'.
PERFORM bdc_field USING 'BDC_OKCODE' '=T13'.
PERFORM bdc_dynpro USING 'SAPMV45A' '4003'.
PERFORM bdc_field USING 'BDC_OKCODE' '/EBACK'.
PERFORM bdc_field USING 'BDC_CURSOR' 'VBAP-ZZRFAR'.
PERFORM bdc_field USING 'VBAP-ZZRWAR' itabi-wcd.
PERFORM bdc_field USING 'VBAP-ZZRFAR' itabi-fcd.
<b> IF sy-tabix >= 2.
*-- from third line onwards start doing '+'
PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=POAN'.
ELSE.
*-- this will increment it to 2 and then the IF will takeover
idx = idx + 1.
ENDIF.</b>
ENDLOOP.
PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.
PERFORM bdc_field USING 'BDC_OKCODE''=SICH'.
‎2006 Mar 24 4:28 PM
Hi Raj,
Please try to code BDC_OKCODE = '/00' after looping 7 times. It should open next 7th line items.
Hope this will help.
Regards,
Ferry Lianto
‎2006 Mar 24 4:49 PM
Hi, as Srinivas post before that should work, I just edited some lines, I guess was just mistyped.
idx = 01.
LOOP AT itabi WHERE ihrez = itabh-ihrez.
PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=POAN'.
CONCATENATE 'VBAP-ABGRU(' idx ')' INTO fnam.
PERFORM bdc_field USING 'BDC_CURSOR' fnam.
CONCATENATE 'RV45A-MABNR(' idx ')' INTO fnam.
PERFORM bdc_field USING fnam itabi-mabnr.
CONCATENATE 'VBAP-ZMENG(' idx ')' INTO fnam.
PERFORM bdc_field USING fnam itabi-zmeng.
CONCATENATE 'VBAP-POSNR(' idx ')' INTO fnam.
PERFORM bdc_field USING fnam itabi-posnr.
CONCATENATE 'VBAP-ABGRU(' idx ')' INTO fnam.
PERFORM bdc_field USING fnam 'Z2'.
PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=PKO1'.
CONCATENATE 'VBAP-POSNR(' idx ')' INTO fnam.
PERFORM bdc_field USING 'BDC_CURSOR' fnam.
PERFORM bdc_dynpro USING 'SAPMV45A' '5003'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
PERFORM bdc_field USING 'BDC_CURSOR' 'KOMV-KSCHL(01)'.
PERFORM bdc_dynpro USING 'SAPMV45A' '5003'.
PERFORM bdc_field USING 'BDC_OKCODE' '=V69A_KOAN'.
PERFORM bdc_field USING 'BDC_CURSOR' 'KOMV-KSCHL(01)'.
PERFORM bdc_dynpro USING 'SAPMV45A' '5003'.
PERFORM bdc_field USING 'BDC_OKCODE' '/00'.
PERFORM bdc_field USING 'BDC_CURSOR' 'KOMV-KWERT(07)'.
PERFORM bdc_field USING 'KOMV-KSCHL(02)' 'ZPR0'.
PERFORM bdc_field USING 'KOMV-KBETR(02)' itabi-kbetr1.
PERFORM bdc_field USING 'KOMV-KSCHL(03)' 'ZPRS'.
PERFORM bdc_field USING 'KOMV-KBETR(03)' itabi-kbetr2.
PERFORM bdc_field USING 'KOMV-KSCHL(04)' 'ZR1'.
PERFORM bdc_field USING 'KOMV-KWERT(04)' itabi-kwert1.
PERFORM bdc_field USING 'KOMV-KSCHL(05)' 'ZLWR'.
PERFORM bdc_field USING 'KOMV-KWERT(05)' itabi-kwert2.
PERFORM bdc_field USING 'KOMV-KSCHL(06)' 'ZLDL'.
PERFORM bdc_field USING 'KOMV-KWERT(06)' itabi-kwert3.
PERFORM bdc_field USING 'KOMV-KSCHL(07)' 'ZLFB'.
PERFORM bdc_field USING 'KOMV-KWERT(07)' itabi-kwert4.
perform bdc_field using 'KOMV-KSCHL(08)'
'ZLBD'.
perform bdc_field using 'KOMV-KWERT(08)'
'0.00'.
PERFORM bdc_dynpro USING 'SAPMV45A' '5003'.
PERFORM bdc_field USING 'BDC_OKCODE' '=T\13'.
PERFORM bdc_dynpro USING 'SAPMV45A' '4003'.
PERFORM bdc_field USING 'BDC_OKCODE' '/EBACK'.
PERFORM bdc_field USING 'BDC_CURSOR' 'VBAP-ZZRFAR'.
PERFORM bdc_field USING 'VBAP-ZZRWAR' itabi-wcd.
PERFORM bdc_field USING 'VBAP-ZZRFAR' itabi-fcd.
<b>IF idx >= 2.</b>
*-- from third line onwards start doing '+'
PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=POAN'.
<b>idx = 1.</b>
ELSE.
*-- this will increment it to 2 and then the IF will takeover
idx = idx + 1.
ENDIF.
ENDLOOP.
PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.
PERFORM bdc_field USING 'BDC_OKCODE''=SICH'.
Another way to do this is, usually the way I go, is to just execute the next two lines for every incoming line:
PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.
PERFORM bdc_field USING 'BDC_OKCODE' '=POAN'.
Hope it Helps.
Regards,
Gilberto Li
‎2006 Mar 24 5:26 PM
Hi Gilberto,
Your changes will work if by pressing the '+' brings a new line as the first one, but in this case I found that it is bringing the new line in the second position. That is why I left idx without resetting it.
‎2006 Mar 24 5:27 PM
Hi,
what about starting from first line.I think this code works from second line.
RAJ
‎2006 Mar 24 5:40 PM
When the loop strated, you enter the value in the first line and then the second line. From the third record of the internal table, you will just enter on thw second line only because of the '+'.
‎2006 Mar 24 6:01 PM
Hi,
There is a BAPI to create credit memos and orders BAPI_SALESORDER_CREATEFROMDAT2. But as you have already worked on the BDC thing you can go ahead with that.
As far as BDC is concerned, you need not pass POSNR, it will automatically pick the next available number(increment by 10). Moreover, you need not initialize idx to 1 as you need to press '+' for all items >= 2.
For the first line you can just type values without pressing '+', only when it comes to line 2 or more you will use '=POAN'. But I recommend you use BAPI for this.
Thanks
Vamsi
‎2006 Mar 24 6:04 PM
Raj,
BDCs are very outdated now. BAPIs are the direction in which you should heading.
When the company with whom you are working goes to upgrade to newer version of SAP, custom BDCs frequently cause headaches as the screens get changed.
You should really re-work your project using BAPIs. Upgrades will be little or NO problem then.
‎2006 Mar 24 7:39 PM
Srinivas,
It almost solved my problem. I am now getting all the lines in order. But somehow the item condition values is not being populated. I can see the value when I debug. But when I run it in background the condition values are not coming in.
Raj
‎2006 Mar 24 7:59 PM
For the conditions, I think you may not be selecting the correct line item. Again, your BDC logic should be such that you always select the second line item(except for the first record of the internal table) and then go to conditions.
Did you consider the suggestions regarding the use of BAPI instead of BDC?
‎2006 Mar 24 10:27 PM
Thanks Srinivas. It solved my problems. I am now able to populate conditions also. I've rewarded you points and also closed the thread.
Once again thanks.
Raj