01-24-2007 9:21 AM
Dear All,
I am running a BDC for VK11. In my input file I am having Condition Type & Sales Org. At every new condition type I am saving the records. Now I want that for every new Condition Type & Sales Org combination the records should be saved.
Current code is defined below:
LOOP AT I_DATA_XLS.
AT NEW KSCHL.
FLAG1 = 'Y'.
ENDAT.
IF FLAG1 = 'Y'.
INT = 0.
PERFORM FILL_BDCDATA USING:
'X' 'SAPMV13A' '0100' ,
' ' 'BDC_CURSOR' 'RV13A-KSCHL' ,
' ' 'BDC_OKCODE' '/00' ,
' ' 'RV13A-KSCHL' I_DATA_XLS-KSCHL ,
'X' 'SAPMV13A' '1600' ,
' ' 'BDC_CURSOR' 'KOMG-VKORG' ,
' ' 'BDC_OKCODE' '/00' ,
' ' 'KOMG-VKORG' I_DATA_XLS-VKORG ,
'X' 'SAPMV13A' '1600' ,
' ' 'BDC_CURSOR' 'RV13A-DATAB(02)' ,
' ' 'BDC_OKCODE' '/00' .
FLAG1 = 'N'.
ENDIF.
How this can be done for a new combination.
Waiting for your replies
Warm Regards,
Nishu Jain.
01-24-2007 9:43 AM
Hi
It depends on how the internal table is structurated: AT NEW <FIELD> event is triggered while a value of field <FIELD> or a field at the left of <FIELD> is changing.
So your table should be:
DATA: BEGIN OF I_DATA_XLS OCCURS 0,
VKORG LIKE VBAK-VKORG,
KSCHL LIKE KONV-KSCHL,
..................................................
END OF I_DATA_XLS.
SORT I_DATA_XLS BY VKORG KSCHL.
LOOP AT I_DATA_XLS.
AT NEW KSCHL.
In this way AT NEW event is triggerd if sales org. or condition are changing.
Max
01-24-2007 9:24 AM
put your first field as Sales organization and second field as Condition type in ur internal table and then the other fields
now use ur same code below , it will work
01-24-2007 9:25 AM
Introduce one more flag flag2 same as flag1 and do this way.
loop .
AT NEW KSCHL.
FLAG1 = 'Y'.
ENDAT
AT NEW vkorg.
FLAG2 = 'Y'.
ENDAT
MAKE THIS AS
IF FLAG1 = 'Y' and FLAG2 = 'Y'.
LOGIC PROCESSING
FLAG1 = 'N'. FLAG2 = 'N'.
ENDIF.
endloop.
regards,
vijay.
see that condition type and sales org are defined side by side in ur internal table or else u will get false values .
remember this.
01-24-2007 9:27 AM
Put sales org as first field & condition as second field. as below
Data: begin of I_DATA_XLS occurs 0,
vkorg like vbak-vkorg,
kchl like ..
field1...
end of I_DATA_XLS.
sort I_DATA_XLS by vkorg kschl.
LOOP AT I_DATA_XLS.
AT NEW KSCHL.
FLAG1 = 'Y'.
ENDAT.
IF FLAG1 = 'Y'.
INT = 0.
PERFORM FILL_BDCDATA USING:
'X' 'SAPMV13A' '0100' ,
' ' 'BDC_CURSOR' 'RV13A-KSCHL' ,
' ' 'BDC_OKCODE' '/00' ,
' ' 'RV13A-KSCHL' I_DATA_XLS-KSCHL ,
'X' 'SAPMV13A' '1600' ,
' ' 'BDC_CURSOR' 'KOMG-VKORG' ,
' ' 'BDC_OKCODE' '/00' ,
' ' 'KOMG-VKORG' I_DATA_XLS-VKORG ,
'X' 'SAPMV13A' '1600' ,
' ' 'BDC_CURSOR' 'RV13A-DATAB(02)' ,
' ' 'BDC_OKCODE' '/00' .
FLAG1 = 'N'.
ENDIF.
01-24-2007 9:28 AM
Instead of writing "at new KSCHL" change it to "At new VKORG"
it should work then..
in any case when you use "at new field", all the fileds on the left side of the field mentioned will be considered. so when ever the combination changes the at new command is triggered.
Make sure that you are sorting your table on KSCHL and VKORG before you start your looping..
-
Santosh
01-24-2007 9:31 AM
in your int table declaration vkorg must come prior to the kschl then only it will work properly but if kschl comes prior to vkorg then put at new vkorg.
regards
shiba dutta
01-24-2007 9:43 AM
Hi
It depends on how the internal table is structurated: AT NEW <FIELD> event is triggered while a value of field <FIELD> or a field at the left of <FIELD> is changing.
So your table should be:
DATA: BEGIN OF I_DATA_XLS OCCURS 0,
VKORG LIKE VBAK-VKORG,
KSCHL LIKE KONV-KSCHL,
..................................................
END OF I_DATA_XLS.
SORT I_DATA_XLS BY VKORG KSCHL.
LOOP AT I_DATA_XLS.
AT NEW KSCHL.
In this way AT NEW event is triggerd if sales org. or condition are changing.
Max
01-24-2007 9:53 AM
Hi,
If VKORG and KSCHL are the first 2 fields in the internal table, then AT NEW KSCHL will work.
If not, we can use ON CHANGE OF as below -
SORT itab BY vkorg kschl.
LOOP AT itab.
ON CHANGE OF itab-vkorg OR itab-kschl.
Write the logic
ENDON.
ENDLOOP.
Hope this helps.
Reward points if found useful...!
Cheers
Abhishek
02-15-2007 7:38 AM