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

Problem with control break statements in internal table

Former Member
0 Likes
1,297

Hi,

I have a internal table which has MATNR, VERID, VORNR, MERKNR, PMETHOD, PHFLG,...etc... I am uploading Master Recipe data in PP..

Material can have many VERID's (Version), and Material & Version combination there may be different VORNR (Operation no)..And one VORNR can have many MERKNR (InspecCharacterstics).

sort itab by MATNR VERID VORNR MERKNR.

Loop at itab.

at new VERID.

*----


endat.

at new VORNR.

*----


endat.

at new MERKNR.

*----


endat.

at end of VORNR.

*----


endat.

at end of VERID.

*----


endat.

Endloop.

Internal table is sorted properly eventhough in the above sequence control levels are not getting executed..

so I decided to use Field-groups and I declared field-groups header, item.

I have inserted MATNR VERID VORNR MERKNR into Header and inserted rest all fields in item.

loop at itab.

extract item.

endloop.

sorted by itab-matnr itab-verid itab-vornr itab-merknr.

loop.

at new itab-verid.

endat.

at new itab-vornr.

endat.

at new itab-merknr.

endat.

endloop.

Still control levels not being triggerd in the given sequence..

Please suggest me on this...

Regards

Jaker.

11 REPLIES 11
Read only

Former Member
0 Likes
1,260

Hi Jaker,

Just move the MATNR field behind the last field you want to use for control breaks.

Regards,

John.

Read only

0 Likes
1,260

Hi John,

I didnt get you..can u please explain me? internal table structure looks like this MATNR VERID VORNR MERKNR..it should work, but I dont know why its not working..

Regards

Jaker.

Read only

0 Likes
1,260

Hi Jaker,

Because MATNR is the first column of your table it is automatically included in control break processing! An AT NEW <field> statement is processed whenever one of the columns to the left of this <Field> is changed and NOT ONLY column <field>.

Regards,

John.

Read only

0 Likes
1,260

Hi John,

Thank you very much for your reply.. for ur reference the test data & internal table structure is as follows.

Material Prd Version Operation Inspec Char

(MATNR) (VERID) (VORNR) (MERKNR)

M1 V1 10

M1 V1 20 1

M1 V1 20 2

M1 V1 30 1

M1 V1 40 1

M1 V1 50 1

-


Call Transaction

M1 V2 10

M1 V2 20 1

M1 V2 20 2

M1 V2 30 1

-


Call Transaction

M2 V1 10

M2 V1 20 1

M2 V1 20 2

M2 V1 30 1

-


Call Transaction

So I have sorted my internal table by MATNR VERID VORNR MERKNR, and the rest process doing as given below.

loop at itab.

at new verid.

  • start filling first screen of transaction

endat.

at new vornr.

  • filling operation data

endat.

at new merknr.

  • filling inspection characteristic data.

endat.

at end of verid.

  • call bdc transaction

endat.

endloop.

In the above case at the end of Version V1 for Material M1, at end of verid should be triggered, but its not happening...but its going to at new verid for Material M1 Version V2.. so I could call bdc transaction at the end of version V1 to save data..

I hope I made it clear this time..Please help me out...

Regards

Jaker.

Read only

0 Likes
1,260

try this it may work.

loop at itab.

at end of verid.

  • call bdc transaction

endat.

at new verid.

  • start filling first screen of transaction

endat.

*or try here

  • on change of itab-verid.

*start filling first screen of transaction

*endon.

*

at new vornr.

  • filling operation data

endat.

at new merknr.

  • filling inspection characteristic data.

endat.

endloop.

just change the position and try as per i have mentioned it may work.

regards

shiba dutta

Read only

0 Likes
1,260

Hi Jaker,

I'm sorry but I have to repeat myself: move the MATNR field to another place in the internal table and make sure you have only fields in the first columns on which you want to do the control break processing.

So make an internal table with VERID VORNR MERKNR MATNR and it should work.

Could you try this?

Regards,

John.

Read only

Former Member
0 Likes
1,260

your first qery is correct dont know why it is not triggering? or you may do on change of itab-matnr like that

regards

shiba dutta

Read only

Former Member
0 Likes
1,260

Hi Jaker,

All at new should be triggered sequentially. For example if the field to left changes the current field even though it remains same triggers at new command . So you should keep in mind while writing at new.

f1 f2 f3 f4

a a a a

1 a a a

now if you put at new at f2 for the second line it'll be triggered even though the value has not changed.

one the solution for this if the data to left changes it'll trigger at new so you should write the sequence accordingly or you should change the internal table structure so that all the field to left of at new field doesn't change.

Thank You

Read only

0 Likes
1,260

Hi,

as described MATNR willnt be changed, so I put it in 1st position and rest VERID VORNR MERKNR will be changed..at new is getting triggered properly but at end of VERID is not triggering...

Regards

Jaker.

Read only

0 Likes
1,260

Move MATNR field to the last in the intrenal table.

Try using read within the loop.

read itab index sy-tabix, after the loop before the "at end of".

I hope it works.

Regards,

Saumya

Read only

0 Likes
1,260

Hi Saumya,

Thank you very much for your reply.. for ur reference the test data & internal table structure is as follows.

Material Prd Version Operation Inspec Char

(MATNR) (VERID) (VORNR) (MERKNR)

M1 V1 10

M1 V1 20 1

M1 V1 20 2

M1 V1 30 1

M1 V1 40 1

M1 V1 50 1

-


Call Transaction

M1 V2 10

M1 V2 20 1

M1 V2 20 2

M1 V2 30 1

-


Call Transaction

M2 V1 10

M2 V1 20 1

M2 V1 20 2

M2 V1 30 1

-


Call Transaction

So I have sorted my internal table by MATNR VERID VORNR MERKNR, and the rest process doing as given below.

loop at itab.

at new verid.

  • start filling first screen of transaction

endat.

at new vornr.

  • filling operation data

endat.

at new merknr.

  • filling inspection characteristic data.

endat.

at end of verid.

  • call bdc transaction

endat.

endloop.

In the above case at the end of Version V1 for Material M1, at end of verid should be triggered, but its not happening...but its going to at new verid for Material M1 Version V2.. so I could call bdc transaction at the end of version V1 to save data..

Please help me out...

Regards

Jaker.