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

Control break statement for more than one fields

Former Member
0 Likes
3,034

How can I accomodate more than 2 fields in control break statement?

e.g. if I want to have control on these fields land1 plant , how can I use it in At statement?

Thanks

1 ACCEPTED SOLUTION
Read only

MarcinPciak
Active Contributor
0 Likes
2,133

You need to handle them both separately.


AT ... LAND1.

ENDAT.

AT ... PLANT.

ENDAT.

Processing will go to AT ... -> ENDAT block each time it fulfill condition in AT operand (i.e NEW, LAST, FIRST etc).

If you want to use both field as one, you will need to create another field and hold there concatenation of LAND1 and PLANT.

Then you can catch it same way


AT ... JOIN_FIELD.   "join field here hold value of LAND1 + PLANT

ENDAT.

Regards

Marcin

14 REPLIES 14
Read only

MarcinPciak
Active Contributor
0 Likes
2,134

You need to handle them both separately.


AT ... LAND1.

ENDAT.

AT ... PLANT.

ENDAT.

Processing will go to AT ... -> ENDAT block each time it fulfill condition in AT operand (i.e NEW, LAST, FIRST etc).

If you want to use both field as one, you will need to create another field and hold there concatenation of LAND1 and PLANT.

Then you can catch it same way


AT ... JOIN_FIELD.   "join field here hold value of LAND1 + PLANT

ENDAT.

Regards

Marcin

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,133

Hey Marcin,

If you define the table as:

DATA:
BEGIN OF ITAB OCCURS 0,
LAND TYPE LAND1,
WERKS TYPE WERKS_D,
END OF ITAB.

Then AT NEW WERKS will be triggered whenever there is change in either LAND or WERKS:

LOOP AT ITAB.
AT NEW WERKS.
ENDAT.
ENDLOOP.

So

If you want to use both field as one, you will need to create another field and hold there concatenation of LAND1 and PLANT

is not required.

Correct me if i am wrong

BR,

Suhas

Edited by: Suhas Saha on Feb 15, 2010 3:14 PM

Read only

0 Likes
2,133

Hi Suhas,

Then AT NEW WERKS will be triggered whenever there is change in either LAND or WERKS:

I don't think so.

Let's say we have below data. Then AT NEW WERKS will get triggered.


LAND    WERKS
01         4030            "<- here (LAND is the same)
01         4030
01         4031           "<- here
01         4031 
01         4032           "<-  here
01         4032          
02         5030          "<- here only LAND and WERKS changes togeter
02         .....

Regards

Marcin

Read only

0 Likes
2,133

I need to have control on both the fields.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,133

Hi Marcin,

But[ SAP documentation |http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb381a358411d1829f0000e829fbfe/content.htm]says:

FIRST
First line of the internal table

LAST
Last line of the internal table

NEW <f>
Beginning of a group of lines with the same contents in the field <f> and in the fields left of <f>

END Of <f>
End of a group of lines with the same contents in the field <f> and in the fields left of <f>

BR,

Suhas

Read only

0 Likes
2,133

NEW <f>

Beginning of a group of lines with the same contents in the field <f> and in the fields left of <f>

Exactly, in the above example whenever WERKS have same value for all rows, LAND will always have same too, not vice versa.

LAND WERKS

01 4030 "<- begining of line with same content of WERKS and same content of LAND (field left of WERKS)

01 4030

01 4031

I just say what I know from authopsy

Regards

Marcin

Read only

0 Likes
2,133

Hi,

Suhas is correct here. Here 'At new WERKS' will be triggered if there is a change in LAND1 or WERKS or BOTH.

In general, At new (f) will ne triggered if there is a change in any of the field contents declared before the field used in at new statement.

Regards,

Ganga

Read only

0 Likes
2,133

>

> Hi,

>

> Suhas is correct here. Here 'At new WERKS' will be triggered if there is a change in LAND1 or WERKS or BOTH.

>

> In general, At new (f) will ne triggered if there is a change in any of the field contents declared before the field used in at new statement.

>

> Regards,

> Ganga

Ok I get what you mean, but one correction. If WEKRS changes this means that either same LAND1 is used or new LAND1 applies.

So correct is that AT NEW WERKS is executed whenever WERKS or BOTH change (beacasue when LAND1 changes WERKS must change too).

@Suhas,

Apologizes for insisting on my theory. I simply misunderstood you.

Regards

Marcin

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,133

Hey Marcin,

No apologies please. In fact i should have re-phrased my statement correctly.

Cheers,

Suhas

Read only

0 Likes
2,133

Whoever faults, it's good we can agree on correct anwser, as there should be only one right:)

Cheers

Marcin

Read only

0 Likes
2,133

Thanks Suhas seems to be correct. Thanks for all your help

Read only

neelavraj_duara2
Explorer
0 Likes
2,133

Control break statement considers every unique combination to the left of the field as a new entry. You just need to ensure that the data is sorted before using control breaks.

Read only

Former Member
0 Likes
2,133

hi,

the control break statements. work corresponding to the first column in the internal table.

if it is the second column in the internal tablee.

then it will consider the value of the first column and then the second column,.

regards,

sakshi.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
2,133

Before applying the control break statements,

Please read the documentation and try once.