In SAP BW, I have an internal table "COMM_STRUCTURE" composed of 52 columns, one for each week of the year.
Rather than appending 52 times to RESULT_TABLE, is there a way to do it in a loop, and traverse each column of a row programatically?
The codes looks like this. I want to eliminate the repeated lines. Thanks for any help.
FORM compute_data_field
TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring
RESULT_TABLE STRUCTURE /BIC/VIC_BUD_JCT
USING COMM_STRUCTURE LIKE /BIC/CSIS_MONBUD
RECORD_NO LIKE SY-TABIX
RECORD_ALL LIKE SY-TABIX
SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS
ICUBE_VALUES LIKE /BIC/VIC_BUD_JCT
CHANGING RETURNCODE LIKE SY-SUBRC
ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update
RESULT_TABLE = ICUBE_VALUES.
RESULT_TABLE-/BIC/IO_BUDINC = COMM_STRUCTURE-/BIC/IO_BAMT01.
RESULT_TABLE-CALMONTH = 200401.
APPEND RESULT_TABLE.
RESULT_TABLE-/BIC/IO_BUDINC = COMM_STRUCTURE-/BIC/IO_BAMT02.
RESULT_TABLE-CALMONTH = 200402.
APPEND RESULT_TABLE.
Hi Jerry,
Please follow this topic and you will find how to achieve the traverse.
Filling fields in work area and counting fields
Regards,
Srinivas
Thanks for the responses. I don't have much experience with ABAP, so I appreciate your patience. I still can't get it to work. The following, which is trying to turn the 52 week columns (ignoring the first column) into 52 rows, doesn't write anything.
Can someone see what my error is?
PROGRAM UPDATE_ROUTINE.
FIELD-SYMBOLS <FS> TYPE ANY.
FORM compute_data_field
TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring
RESULT_TABLE STRUCTURE /BIC/VIC_BUD_JCT
USING COMM_STRUCTURE LIKE /BIC/CSIS_MONBUD
RECORD_NO LIKE SY-TABIX
RECORD_ALL LIKE SY-TABIX
SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS
ICUBE_VALUES LIKE /BIC/VIC_BUD_JCT
CHANGING RETURNCODE LIKE SY-SUBRC
ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update
RESULT_TABLE = ICUBE_VALUES.
DO.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE COMM_STRUCTURE TO <FS>.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
IF SY-INDEX > 1.
RESULT_TABLE-/BIC/IO_BUDAMT = <FS>.
RESULT_TABLE-CALMONTH = SY-INDEX.
APPEND RESULT_TABLE.
ENDIF.
ENDDO.
RETURNCODE = 0.
ABORT = 0.
ENDFORM.
Add a comment