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

AT NEW Command

Former Member
0 Likes
1,031

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,003

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

8 REPLIES 8
Read only

Former Member
0 Likes
1,003

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

Read only

Former Member
0 Likes
1,003

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.

Read only

Former Member
0 Likes
1,003

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.

Read only

Former Member
0 Likes
1,003

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

Read only

Former Member
0 Likes
1,003

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

Read only

Former Member
0 Likes
1,004

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

Read only

Former Member
0 Likes
1,003

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

Read only

Former Member
0 Likes
1,003

Thanks for your valuable replies.