Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Loop At Assigning syntax question

I have a table that I want to reverse the values of each of the numeric fields. I want to use a Loop At I_TABLE assigning <fs>. Then within that structure I want to calculate the inverse of each of the fields in the internal table containing the appropriate field names. Here is my sample code:

*Loop at each record in internal table...

LOOP AT DATA_PACKAGE assigning <DP>.

  • Loop at table with numeric field names

LOOP AT I_DD03L INTO WA_DD03L.

MOVE WA_DD03L-FIELDNAME TO FNAME.

ASSIGN (FNAME) TO <F>.

  • Reverse each numeric field in <DP>

<DP>-<F> = <DP>-<F> * (-1).

ENDLOOP.

ENDLOOP.

I get an error that states <DP>-<F> does not exist.

Any ideas?

Tags:
Former Member
Former Member replied

new enhanced version....

<b>DATA: i_dd03l TYPE dd03l OCCURS 0 WITH HEADER LINE.

DATA: data_package TYPE t001 OCCURS 0.

DATA: fname(61).

DATA: wa_t001 TYPE t001.

FIELD-SYMBOLS: <dp> STRUCTURE wa_t001 DEFAULT wa_t001, <f>.

SELECT * FROM t001 INTO TABLE data_package.

SELECT * FROM dd03l INTO TABLE i_dd03l WHERE tabname EQ 'T001'.

*Loop at each record in internal table...

LOOP AT data_package ASSIGNING <dp>.

NEW-LINE.

  • Loop at table with numeric field names

LOOP AT i_dd03l.

CONCATENATE '<DP>-' i_dd03l-fieldname INTO fname.

ASSIGN (fname) TO <f>.

IF i_dd03l-fieldname EQ 'BUTXT'.

<f> = 'Rishi'.

ENDIF.

ENDLOOP.

ENDLOOP.

  • contents have changed without modify

LOOP AT data_package ASSIGNING <dp>.

WRITE / <dp>.

ENDLOOP.</b>

notice that there is no modify.

Rishi

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question