Skip to Content
author's profile photo Former Member
Former Member

Traverse Columns in Internal Table Programatically

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 07, 2005 at 08:26 PM

    Yes, you can use Field Symbols <fs>

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 07, 2005 at 09:47 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2005 at 02:34 PM

    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
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.