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

Displaying dynamic table in OOPS ALV

Hi,

I am creating a dynamic internal table which consists of some fields which are being filled dynamically and some fields which are being filled from a static internal table. I am facing two issues in the development:-

1. The static fields are being populated into the dynamic work area successfully but I am not able to modify the dynamic in ternal table using the work area.

PFB my code:

READ TABLE I_LEVEL1 WITH KEY KSCHL = WA_T681-KSCHL
                                       KOTABNR = WA_T681-KOTABNR.
          IF SY-SUBRC EQ 0.
            <WA_DYN_TABLE1>-UDATE    = I_LEVEL1-UDATE.
            <WA_DYN_TABLE1>-UTIME    = I_LEVEL1-UTIME.
            
            MOVE-CORRESPONDING <WA_DYN_TABLE1> TO <WA_DYN_TABLE>.

            MODIFY <I_DYN_TABLE> FROM <WA_DYN_TABLE> TRANSPORTING UDATE
                                                                  UTIME.

The dynamic filds of <I_DYN_TABLE> are being populated successfully but the MODIFY statement gives an error.

The specified type has no structure and therefore no component called UDATE.

2. The other problem I am facing is that while displaying output for the same ALV, no column names are being displayed.

I am using OOPS ALV.

PFB my code for the same:

CL_SALV_TABLE=>FACTORY( IMPORTING R_SALV_TABLE = O_TABLE
                              CHANGING  T_TABLE      = <I_DYN_TABLE> ).


      O_FUNCTIONS = O_TABLE->GET_FUNCTIONS( ).
      O_FUNCTIONS->SET_ALL( ABAP_TRUE ).

      O_COLUMNS = O_TABLE->GET_COLUMNS( ).
      O_COLUMNS->SET_OPTIMIZE( 'X' ).

Please help me regarding the issues.

Thanks.

Edited by: Suhas Saha on Jan 18, 2012 3:11 PM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Jan 18, 2012 at 09:56 AM

    Hello Deepak,

    You can use dynamic tokens while using TRANSPORTING addition:

    MODIFY <I_DYN_TABLE> FROM <WA_DYN_TABLE> TRANSPORTING ('UDATE') ('UTIME').

    Regarding column names not being displayed in the ALV, can you paste the code for populating the dynamic table <I_DYN_TABLE>?

    BR,

    Suhas

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Suhas,

      Thank you for the reply. The modify problem has been solved.

      Regarding the heading issue:

      Here is the code for populating the table:-

      LOOP AT I_TY_FIELD INTO WA_TY_FIELD.

      WA_DYN_IT-FIELDNAME = WA_TY_FIELD-FIELDNAME.

      WA_DYN_IT-TABNAME = WA_TY_FIELD-TABNAME.

      WA_DYN_IT-DATATYPE = WA_TY_FIELD-DATATYPE.

      WA_DYN_IT-INTTYPE = WA_TY_FIELD-INTTYPE.

      WA_DYN_IT-INTLEN = WA_TY_FIELD-INTLEN.

      WA_DYN_IT-SCRTEXT_M = WA_TY_FIELD-FIELDDESC.

      APPEND WA_DYN_IT TO I_DYN_IT.

      CLEAR: WA_DYN_IT.

      ENDLOOP.

      CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE

      EXPORTING

      IT_FIELDCATALOG = I_DYN_IT

      IMPORTING

      EP_TABLE = I_DY_TABLE.

      ASSIGN I_DY_TABLE->* TO <I_DYN_TABLE>.

      ASSIGN <I_DYN_TABLE> TO <FS_2>.

      • Create dynamic work area and assign to FS

      CREATE DATA I_DY_LINE LIKE LINE OF <I_DYN_TABLE>.

      ASSIGN I_DY_LINE->* TO <WA_DYN_TABLE>.

      I_TY_FIELD contains all static and dynamic fields.

      Is there any field of I_DYN_IT i need to fill I have missed which fills up the column header data?

  • author's profile photo Former Member
    Former Member
    Posted on Jan 18, 2012 at 03:21 AM

    Hi ,

    check sample code for point 1.

    
    
      field-symbols : <fs1>  type any,
                             <fs2>   type any.
    
    
    if <fs1>i is assigned .
       unassign <fs1>.
    endif.
    
    READ TABLE I_LEVEL1 WITH KEY KSCHL = WA_T681-KSCHL
    KOTABNR = WA_T681-KOTABNR.
    IF SY-SUBRC EQ 0.
    
    assign(<WA_DYN_TABLE1>-UDATE') to <fs1>.
    assign(<WA_DYN_TABLE1>-UTIME) to <fs2>.
    
    if <fs1> is assigned.
    <fs1> = I_LEVEL1-UDATE.
    endif.
    if <fs2> is assigned.
    <fs2> = I_LEVEL1-UTIME.
    endif.
    
    

    regards

    Prabhu

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Prabhu,

      Thanks for your reply. But this doesnt wowk and I get error that <FS2> cannot be converted to ILEVEL1-UDATE.

      The main problem is the MODIFY statement. Could you please suggest regarding that?

  • author's profile photo Former Member
    Former Member
    Posted on Jan 18, 2012 at 11:57 AM

    Problem of column header persists.

    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.