Adding Specific columns of dynamic internal table row into another column

Hi Gurus,
I need to add  few columns of a dynamic internal table row into another column:
Article description hy01 hy02 total
101      panza         10     12      22
102      masht         12     12     24
dynamic internal table is created and columns hy01 hy02.... can increase
How to add the the values in hy01 hy 02... into total.
Regards,
Dep

Hi,
If you really want to have a dynamic table, then you will have to find a way to generate a whole new table, and then copy the data from the old table to the new one. There is no way to modify a type during runtime in ABAP.
Here an example how to generate a dynamic table based on another internal table, hope this will help you.
TYPE-POOLS: slis.
PARAMETERS: p_nb_hy TYPE i DEFAULT 2. "Number of new HY columns to be added
* Type ZST_T:
*   matnr  TYPE matnr
*   maktx  TYPE maktx
*   hy01   TYPE i
*   total  TYPE i
TYPES: ty_t TYPE STANDARD TABLE OF zst_s.
PERFORM main.
*&      Form  main
*       text
FORM main.
  DATA: lt_fieldcat     TYPE slis_t_fieldcat_alv,
        lt_t            TYPE ty_t,
        lr_new_t        TYPE REF TO data.
  FIELD-SYMBOLS: <lt_new_t> TYPE STANDARD TABLE.
  "Add some lines to LT_T just to have something to display on screen
  DO 10 TIMES.
    APPEND INITIAL LINE TO lt_t.
  ENDDO.
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name = 'ZST_S'
    CHANGING
      ct_fieldcat      = lt_fieldcat.
  "Copy LT_T to LR_NEW_T
  PERFORM extend_and_copy_table USING lt_t p_nb_hy CHANGING lr_new_t lt_fieldcat.
  CLEAR lt_t. "Not needed anymore...
  ASSIGN lr_new_t->* TO <lt_new_t>.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      it_fieldcat = lt_fieldcat
    TABLES
      t_outtab    = <lt_new_t>.
ENDFORM.                    "main
*&      Form  extend_and_copy_table
FORM extend_and_copy_table USING ut_t           TYPE STANDARD TABLE
                                 uv_nb_hy       TYPE i
                           CHANGING cr_t        TYPE REF TO data
                                    ct_fieldcat TYPE slis_t_fieldcat_alv
                           RAISING cx_sy_struct_creation cx_sy_table_creation.
  DATA: lo_tabledescr      TYPE REF TO cl_abap_tabledescr,
        lo_structdescr     TYPE REF TO cl_abap_structdescr,
        lo_new_structdescr TYPE REF TO cl_abap_structdescr,
        lo_new_tabledescr  TYPE REF TO cl_abap_tabledescr,
        lt_components      TYPE cl_abap_structdescr=>component_table,
        ls_component       TYPE cl_abap_structdescr=>component,
        lv_field_cnt       TYPE numc2,
        ls_fieldcat        TYPE slis_fieldcat_alv,
        lr_fieldcat        TYPE REF TO slis_fieldcat_alv.
  FIELD-SYMBOLS: <ls_old_s> TYPE ANY,
                 <lt_new_t> TYPE STANDARD TABLE,
                 <ls_new_s> TYPE ANY.
  "Get the list of all components from UT_T line structure
  lo_tabledescr  ?= cl_abap_tabledescr=>describe_by_data( ut_t ).
  lo_structdescr ?= lo_tabledescr->get_table_line_type( ).
  lt_components  = lo_structdescr->get_components( ).
  "The new columns will be from type of column HY01
  ls_component-type = lo_structdescr->get_component_type( 'HY01' ).
  "The new columns will have the same fieldcat info as column HY01
  READ TABLE ct_fieldcat INTO ls_fieldcat WITH KEY fieldname = 'HY01'.
  "HY<lv_field_cnt> = new field name
  lv_field_cnt = uv_nb_hy + 1.
  "For each new column...
  DO uv_nb_hy TIMES.
    "Generate the new column field name
    CONCATENATE  'HY' lv_field_cnt INTO ls_component-name.
    ls_fieldcat-fieldname = ls_component-name.
    "Add the new field to the components of the new structure
    INSERT ls_component INTO lt_components INDEX 4.
    "Add the new field's fieldcat info to the fieldcat
    INSERT ls_fieldcat  INTO ct_fieldcat   INDEX 4.
    lv_field_cnt = lv_field_cnt - 1.
  ENDDO.
  "Adjust the COL_POS from fieldcat
  LOOP AT ct_fieldcat REFERENCE INTO lr_fieldcat.
    lr_fieldcat->col_pos = sy-tabix.
  ENDLOOP.
  "Create the new table
  lo_new_structdescr = cl_abap_structdescr=>create( p_components = lt_components ).
  lo_new_tabledescr  = cl_abap_tabledescr=>create( p_line_type = lo_new_structdescr ).
  CREATE DATA cr_t TYPE HANDLE lo_new_tabledescr.
  ASSIGN cr_t->* TO <lt_new_t>.
  "Copy all data from old to new table
  LOOP AT ut_t ASSIGNING <ls_old_s>.
    APPEND INITIAL LINE TO <lt_new_t> ASSIGNING <ls_new_s>.
    MOVE-CORRESPONDING <ls_old_s> TO <ls_new_s>.
  ENDLOOP.
ENDFORM.                    "main

Similar Messages

  • Hide or Delete Empty columns in dynamic internal table

    Hi,
                                I am having an dynamic internal table which contains more than 100 columns.
             I need to delete empty column from that table, can any one help this.

    Hello,
    If you are talking about ALV then you can just the the table for empty columns before populating fieldcataloge and hide the columns.
    If your query is still not answered please provide a detail requirement.

  • Passing Dynamic Internal Table values to another program

    Hi,
    I have a program ZSAPNEW.
    In this I have created a Dynamic internal table <fs_emp>. The number of fields differ for each run. The values are passed into <fs_emp> in this program.  Now I need to submit thsi program from a main program ZHEAD and then display the values got from ZHEAD. For this I need to access the values retrieved from ZSAPNEW in <fs_emp> in ZHEAD. I cant figure out how to do this. I tried IMPORT ing the reference of teh field symbol too/ But its not allowing references in IMPORT/EXPORT. And since the table is of type ANY( as structure varies) I cant assign it to an internal table and then pass. Can some one suggest a solution please.
    Suzie

    Hi
    You need to know how the strcture of your table is generated In both programm:
    - Calling program:
    DATA: LR_VALUE_DESCR  TYPE REF TO CL_ABAP_ELEMDESCR,
          COMPONENT       TYPE CL_ABAP_STRUCTDESCR=>COMPONENT,
          LT_COMPONENTS   TYPE CL_ABAP_STRUCTDESCR=>COMPONENT_TABLE.
    DATA: LT_STRUC        TYPE REF TO CL_ABAP_STRUCTDESCR,
          LT_TAB          TYPE REF TO CL_ABAP_TABLEDESCR.
    DATA: L_INDEX TYPE C.
    DATA: W_LINE          TYPE REF TO DATA,
          INT_TABLE       TYPE REF TO DATA.
    FIELD-SYMBOLS: <WA>    TYPE ANY,
                   <ITAB>  TYPE TABLE,
                   <VALUE> TYPE ANY.
    DO 4 TIMES.
      CLEAR COMPONENT.
      MOVE SY-INDEX TO L_INDEX.
      CONCATENATE 'FIELD' L_INDEX INTO COMPONENT-NAME.
      MOVE CL_ABAP_ELEMDESCR=>GET_C( P_LENGTH = 4 ) TO LR_VALUE_DESCR.
      COMPONENT-TYPE = LR_VALUE_DESCR.
      INSERT COMPONENT INTO TABLE LT_COMPONENTS.
    ENDDO.
    * Workarea
    LT_STRUC = CL_ABAP_STRUCTDESCR=>CREATE( P_COMPONENTS = LT_COMPONENTS
                                                       P_STRICT     = 'X' ).
    CREATE DATA W_LINE TYPE HANDLE LT_STRUC.
    ASSIGN W_LINE->* TO <WA>.
    * Table
    LT_TAB = CL_ABAP_TABLEDESCR=>CREATE( P_LINE_TYPE = LT_STRUC ).
    CREATE DATA INT_TABLE TYPE HANDLE LT_TAB.
    ASSIGN INT_TABLE->* TO <ITAB>.
    DO 3 TIMES.
      CLEAR <WA>.
      DO 4 TIMES.
        MOVE SY-INDEX TO L_INDEX.
        CONCATENATE 'FIELD' L_INDEX INTO COMPONENT-NAME.
        ASSIGN COMPONENT COMPONENT-NAME OF STRUCTURE <WA> TO <VALUE>.
        MOVE SY-INDEX TO <VALUE>.
      ENDDO.
      APPEND <WA> TO <ITAB>.
    ENDDO.
    DATA: WA_INDX TYPE INDX.
    WA_INDX-USERA = SY-UNAME.
    WA_INDX-PGMID = 'MAXMAX'.
    EXPORT TAB = <ITAB>
      TO DATABASE INDX(XY)
      FROM WA_INDX
      CLIENT SY-MANDT
      ID 'TABLE'.
    Called program:
    DATA: LR_VALUE_DESCR  TYPE REF TO CL_ABAP_ELEMDESCR,
          COMPONENT       TYPE CL_ABAP_STRUCTDESCR=>COMPONENT,
          LT_COMPONENTS   TYPE CL_ABAP_STRUCTDESCR=>COMPONENT_TABLE.
    DATA: LT_STRUC        TYPE REF TO CL_ABAP_STRUCTDESCR,
          LT_TAB          TYPE REF TO CL_ABAP_TABLEDESCR.
    DATA: L_INDEX TYPE C.
    DATA: W_LINE          TYPE REF TO DATA,
          INT_TABLE       TYPE REF TO DATA.
    FIELD-SYMBOLS: <WA>    TYPE ANY,
                   <ITAB>  TYPE TABLE,
                   <VALUE> TYPE ANY.
    DO 4 TIMES.
      CLEAR COMPONENT.
      MOVE SY-INDEX TO L_INDEX.
      CONCATENATE 'FIELD' L_INDEX INTO COMPONENT-NAME.
      MOVE CL_ABAP_ELEMDESCR=>GET_C( P_LENGTH = 4 ) TO LR_VALUE_DESCR.
      COMPONENT-TYPE = LR_VALUE_DESCR.
      INSERT COMPONENT INTO TABLE LT_COMPONENTS.
    ENDDO.
    * Workarea
    LT_STRUC = CL_ABAP_STRUCTDESCR=>CREATE( P_COMPONENTS = LT_COMPONENTS
                                                       P_STRICT     = 'X' ).
    CREATE DATA W_LINE TYPE HANDLE LT_STRUC.
    ASSIGN W_LINE->* TO <WA>.
    * Table
    LT_TAB = CL_ABAP_TABLEDESCR=>CREATE( P_LINE_TYPE = LT_STRUC ).
    CREATE DATA INT_TABLE TYPE HANDLE LT_TAB.
    ASSIGN INT_TABLE->* TO <ITAB>.
    DATA: WA_INDX TYPE INDX.
    WA_INDX-USERA = SY-UNAME.
    WA_INDX-PGMID = 'MAXMAX'.
    IMPORT TAB = <ITAB>
      FROM DATABASE INDX(XY)
      TO WA_INDX
      CLIENT SY-MANDT
      ID 'TABLE'.
    LOOP AT <ITAB> ASSIGNING <WA>.
      WRITE: / <WA>.
    ENDLOOP.
    The sample above use IMPORT/EXPORT from database: if the called program can't know the structure of the dynaic table, you need to transfer it by the same way you transfer the data
    Max

  • Adding the field in the internal table based on another field

    Hi all,
    I am Creating a Function module with three fields (HKONT,EBELN,DMBTR) in the output internal table(ITAB)
    My Requirement is that as soon as the value of the HKONT in the internal table changes,  i need to sum the DMBTR field values  and should pass into a variable(v_sum).
    ON CHANGE OF seems to me Obsolete.
    Please help me in doing this.
    Thanks
    Ajay

    HI,
         Use control break event . AT END OF.
         loop at ITAB.
           V_DMBTR = V_DMBTR + ITAB-DMBTR.
           at end of HKONT.
              v_sum =  V_DMBTR.
              clear : V_DMBTR.
           endat.
         endloop.
    Regards,
    Srini.

  • Internal table rows to columns

    hi
    i have an internal table with foll strcuture
    customer jan feb mar apr jun july aug sep oct nov  dec
    a             1    2    3    4    5   6     7     8     9  10   11
    b
    c
    n
    i need to form another internal table whose ouput will be
    month custA cust B custc cust d
    jan 1
    feb 2
    mar 3
    so depending upon the no of records of  first internal table, columns need to be created in the new table with corresponding cusomters data.
    how to proceed ?

    Check the links -
    converting columns to rows
    Convert Internal table Rows into columns of another internal table
    Re: Moving columns of an internal table to rows of an another internal table.
    Regards,
    Amit
    Reward all helpful replies.

  • Dynamic Internal Table with Dynamic Fields

    Hi all,
    My scenario is fairly simple----
    --> End user clicks a button on screen and he gets the list of HR tables.
    --> Then selects a table and list of all the fields for that table gets displayed.
    --> He/she selects the fields they want data to be retrieved for.
    So, the requirement is, the dynamic internal table should get created with the fields selected.
    The select statement should only retrieve fields which were selected by the end user
    and from the table selected by the end user.
    I  believe the fields selected by end user can be passed by a variable of  type string.
    something like this---
    select (fields)
    from (p_table)        " Table selected by end user
    into  dynamic internal table.   " should contain columns selected by end user"
    Appreciate your inputs and guidance.
    Warm regards,
    Hari Kiran

    TYPE-POOLS :ABAP.
    Parameters P_TAB      TYPE        DDOBJNAME.
    DATA  : GO_LINE_TYPE  TYPE REF TO CL_ABAP_STRUCTDESCR,
            GO_TABLE_DESC TYPE REF TO CL_ABAP_TABLEDESCR,
            GS_COMPONENTS TYPE        ABAP_COMPONENTDESCR,
            GT_COMPONENTS TYPE        ABAP_COMPONENT_TAB,
            GR_TAB        TYPE REF TO DATA,
            GT_FIELDS  TYPE TABLE OF DFIES WITH HEADER LINE.
    FIELD-SYMBOLS: <GT_TABLE> TYPE TABLE,
                   <GS_TABLE> TYPE ANY,
                   <GV_VALUE> TYPE ANY.
    CALL FUNCTION 'DDIF_FIELDINFO_GET'
      EXPORTING
        TABNAME              = P_TAB
    *   FIELDNAME            = ' '
    *   LANGU                = SY-LANGU
    *   LFIELDNAME           = ' '
    *   ALL_TYPES            = ' '
    *   GROUP_NAMES          = ' '
    *   UCLEN                =
    * IMPORTING
    *   X030L_WA             =
    *   DDOBJTYPE            =
    *   DFIES_WA             =
    *   LINES_DESCR          =
    TABLES
        DFIES_TAB            =  GT_FIELDS
    *   FIXED_VALUES         =
    EXCEPTIONS
       NOT_FOUND            = 1
       INTERNAL_ERROR       = 2
       OTHERS               = 3.
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    LOOP AT GT_FIELDS.
      CLEAR GS_COMPONENTS.
      GS_COMPONENTS-NAME  = GT_FIELDS-FIELDNAME.
      GS_COMPONENTS-TYPE ?= CL_ABAP_STRUCTDESCR=>DESCRIBE_BY_NAME( GT_FIELDS-ROLLNAME ).
      APPEND GS_COMPONENTS TO GT_COMPONENTS.
    ENDLOOP.
    GO_LINE_TYPE  = CL_ABAP_STRUCTDESCR=>CREATE( GT_COMPONENTS ).
    GO_TABLE_DESC = CL_ABAP_TABLEDESCR=>CREATE( GO_LINE_TYPE ).
    CREATE DATA:  GR_TAB TYPE HANDLE GO_TABLE_DESC.
    ASSIGN:  GR_TAB->* TO <GT_TABLE>.
    SELECT * FROM (P_TAB) APPENDING CORRESPONDING FIELDS OF TABLE <GT_TABLE>.
    LOOP AT <GT_TABLE> ASSIGNING <GS_TABLE>.
      NEW-LINE.
      DO.
        ASSIGN COMPONENT SY-INDEX OF STRUCTURE <GS_TABLE> TO <GV_VALUE>.
        IF SY-SUBRC NE '0'.
          EXIT.
        ENDIF.
        WRITE : <GV_VALUE>.
      ENDDO.
    ENDLOOP.

  • Dynamic internal table- column to row conversion

    Hello all,
    Inside a program i generate a dynamic internal table and
    This table has one single column. But I need to convert the rows as columns.
    Eg:
    dynamic internal table ITAB has content
    Forbes
    Times
    Reuters
    Warner
    stern
    I would like to have a ITAB2 like this
    Forbes Times Reuters Warner Stern
    Please note this is a Dynamic internal table!!!!
    I need some approach for my problem. Thanks a lot in advance.
    Karthik.

    Hi karthik,
    1.
      For this purpose,
      in my program,
    <b>  there is an INDEPENDENT FORM</b>
       whose inputs are
    <b>  LIST OF FIELDS, (just as u require)</b> 
    and from those, it consructs dynamic table.
    2. Here is the program.
    the dynamic table name will be
    <DYNTABLE>.
    3. U can use this program (FORM in this program)
    to generate any kind of internal table
    by specifying list of fields.
    4.
    REPORT abc.
    COMPULSORY
    FIELD-SYMBOLS: <dyntable> TYPE ANY TABLE.
    FIELD-SYMBOLS: <dynline> TYPE ANY.
    DATA: lt TYPE lvc_t_fcat.
    DATA: ls TYPE lvc_s_fcat.
    FIELD-SYMBOLS: <fld> TYPE ANY.
    DATA : fldname(50) TYPE c.
    DATA : ddfields LIKE ddfield OCCURS 0 WITH HEADER LINE.
    START-OF-SELECTION.
    field list
      ddfields-fieldname = 'BUKRS'.
      APPEND DDFIELDS.
      ddfields-fieldname = 'MATNR'.
      APPEND DDFIELDS.
      PERFORM mydyntable .
    see <DYNTABLE> in debug mode.
      BREAK-POINT.
    INDEPENDENT FORM
    FORM mydyntable .
    Create Dyn Table From FC
      FIELD-SYMBOLS: <fs_data> TYPE REF TO data.
      FIELD-SYMBOLS: <fs_1>.
      FIELD-SYMBOLS: <fs_2> TYPE ANY TABLE.
      DATA: lt_data TYPE REF TO data.
      data : lt TYPE lvc_t_fcat .
    CONSTRUCT FIELD LIST
      LOOP AT ddfields.
        ls-fieldname = ddfields-fieldname.
        APPEND ls TO lt.
      ENDLOOP.
      ASSIGN lt_data TO <fs_data>.
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog           = lt
        IMPORTING
          ep_table                  = <fs_data>
        EXCEPTIONS
          generate_subpool_dir_full = 1
          OTHERS                    = 2.
      IF sy-subrc <> 0.
      ENDIF.
    Assign Dyn Table To Field Sumbol
      ASSIGN <fs_data>->* TO <fs_1>.
      ASSIGN <fs_1> TO <fs_2>.
      ASSIGN <fs_1> TO <dyntable>.
    ENDFORM. "MYDYNTABLE
    regards,
    amit m.

  • Modifying Internal Table row - The column name is dynamic

    Hi,
    I need to update the internal table as described below,
    Assume that i have 10 columns in my internal table and i need to modifying the column value in row, which is dynamic.
    for example, i'm writing it in Subroutine and it has 3 formal parameter
    1) Key field value
    2) Column name
    3) Value of the column
    in my subroutine i need to write code to modify the row, which should handle the columns dynamically.
    Samples,
    7th record i need to modify the 4th column value.
    4th record i need to modify the 9th column value.
    Please guide me to handle this requirement.write me if i'm not clear.
    ...Nandha

    For the column check the ASSIGN statement:
    No system here, but I think it is:
    ASSIGN COMPONENT <index> OF STRUCTURE <structure> TO <field-symbol>.
    For the row:
    READ TABLE <itab> INDEX <index> INTO <work area>.
    --> For your 1. example you could write:
    READ TABLE <itab> INDEX 7 INTO <work area>.
    ASSIGN COMPONENT 4 OF STRUCTURE <work area> TO <field-symbol>.
    <field symbol> now points to the 4th column of the 7th row.
    Guenther

  • ALV rows to column dynamic internal table

    Hello People ,
    I am stuck in a report which displays an output in ALV as follows :-
    bukrs | kntyp | konto | knfix  | period     | element    | emeng  | emein
    1000  | 10      | 1100 | berlin | 11.2011  |      AG      |  0.148    | kgAG
    1000  | 10      | 1100 | berlin | 11.2011  |      AU      | 0.104    | kgAU
    1000  | 10      | 1100 | berlin | 11.2011  |      GA     | 0.207    | kgGA
    And this table has many values corresponding to element AG,AU and GA respectively . For example , there would be many element AG's with many "EMENG" values . Similarly for AU and GA .
    MY question :- I am asked to make AG , AU , GA as 3 different fields which should show the value "EMENG" under respective elements . Like :-
    bukrs | kntyp | konto | knfix  | period     |   AG       |   AU      |  GA     |    emein
    1000  | 10      | 1100 | berlin | 11.2011  |   0.148    |   0.104  |  0.207 |    kgAG
    That should be my output . ( elements replaced by AG , AU and GA which comes from a Metal table ZXXXX where
    metal no. 1 = AU
    metal no. 2 = AG
    metal no. 3 = GA
    If there is any metal added to it would be metal no. 4 ,5,6,7 .... so on ) and then that should be added as a field in our report .. So that has to be DYNAMIC .
    I am unable to move on with problem . Pls suggest ? I am pasting my report here ...
    FORM select_table_gt_bb CHANGING p_gt_bb.
      TABLES : zpam_as .
      DATA : i_zpam_as TYPE TABLE OF zpam_as ,
             wa_zpam_as LIKE LINE OF i_zpam_as ,
             i_tcurr TYPE TABLE OF tcurr ,
             wa_tcurr LIKE LINE OF i_tcurr,
             zt_as TYPE TABLE OF zpam_as.
      SELECT * FROM zpam_as INTO TABLE gt_as
             WHERE bukrs   EQ bukrs
               AND kntyp   IN kntyp
               AND konto   IN konto
               AND knfix   IN knfix
               AND buper   IN buper
               AND element IN element
               AND ameng   IN ameng
               AND ashkz   IN ashkz
               AND emeng   IN emeng
               AND eshkz   IN eshkz
               AND emein   IN emein.
      SELECT * FROM zpam_tcurr INTO TABLE gt_tcurr.
      IF sy-subrc IS INITIAL.
        LOOP AT gt_tcurr INTO gw_tcurr.
         SELECT * FROM tcurr INTO wa_tcurr WHERE fcurr = gw_tcurr-fcurr AND
         tcurr = tcurr.
          ENDSELECT.
          APPEND wa_tcurr TO i_tcurr.
          DELETE ADJACENT DUPLICATES FROM i_tcurr.
        ENDLOOP.
      ENDIF.
      IF i_tcurr IS NOT INITIAL.
        LOOP AT gt_as INTO gw_as.
    CLEAR sy-subrc.
    LOOP AT i_tcurr
    INTO wa_tcurr
    WHERE   fcurr = gw_as-emein.
            gw_as-tcurr = wa_tcurr-tcurr.
            gw_as-ukurs = wa_tcurr-ukurs.
            gw_as-total = abs( gw_as-emeng ) * wa_tcurr-ukurs.
            APPEND gw_as TO zt_as.
          ENDLOOP.
          IF sy-subrc <> 0.
            gw_as-tcurr = 'None'.
            gw_as-ukurs = ''.
            gw_as-total = ''.
            APPEND gw_as TO zt_as.
          ENDIF.
        ENDLOOP.
        REFRESH gt_as.
        LOOP AT zt_as INTO gw_as.
          APPEND gw_as TO gt_as.
        ENDLOOP.
      ENDIF.
    ENDFORM.
    Priority normalized
    Edited by: Rob Burbank on Dec 28, 2011 3:44 PM

    Hey,
    But after understanding my question correctly , you sure that dynamic internal table is the solution for it ?

  • No column text displayed in alv when i use dynamic internal table

    Hi friends,
    when I use dynamic internal table to display the fields in ALV formant, field column text was not displaying ,
    total row of column text was blank.
    can u sujjest me in this...
    with regards,
    prasad.

    Hi
    That depends on how you've filled the catalog table, here u need to insert the description for the labels (short, medium and long) and the description for the layout variant management.
    So u make sure to fill the fields like
    SCRTEXT_L
    SCRTEXT_M
    SCRTEXT_S
    REPTEXT
    Max

  • How to find the number of columns in an internal table DYNAMICALLY ?

    Hi,
    How to find the number of columns in an internal table DYNAMICALLY ?
    Thanks and Regards,
    saleem.

    Hi,
    you can find the number of columns and their order using
    the <b>'REUSE_ALV_FIELDCATALOG_MERGE'</b>
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
       I_PROGRAM_NAME               = sy-repid
       I_INTERNAL_TABNAME           = 'ITAB'
       I_INCLNAME                   = sy-repid
      changing
        ct_fieldcat                  = IT_FIELDCAT
    EXCEPTIONS
       INCONSISTENT_INTERFACE       = 1
       PROGRAM_ERROR                = 2
       OTHERS                       = 3
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif
    now describe your fieldcat . and find no of columns.
    and their order also..
    regards
    vijay

  • Column names of a dynamic internal table

    Hi Friends,
    I have a dynamic internal table flowing in my ABAP program and I want to list down the column names of the this dynamic internal table.
    The declaration of this dynamic internal table :
       FIELD-SYMBOLS:
        <l_t_data>         TYPE STANDARD TABLE.
    Can you please tell me how to get the column names?
    Thanks,
    Gaurav

    Hi,
         You can use ABAP Runtime Type Identification to get the column names of the internal table.
    e.g >
    >lo_itab holds reference to description object of internal table whose column names i have to extract.
    >Using method describe_by_data of class cl_abap_typedescr export the field symbol assigned to the table and import the object reference into lo_itab.
    >Then using method get_table_line_type of lo_itab import line type description object reference into lo_line.
    >Check if lo_line is referring to a structure, if yes , downcast it to a object reference lo_struct of type cl_abap_structdescr.
    >The column description of all columns in the structure is stored in 'components' table of cl_abap_structdescr.
         So loop at the table to get all the column names stored in column 'name' of table 'components'.
    Thank You.

  • How to create Dynamic internal table with columns also created dynamically.

    Hi All,
    Any info on how to create a dynamic internal table along with columns(fields) also to be created dynamically.
    My requirement is ..On the selection screen I enter the number of fields to be in the internal table which gets created dynamically.
    I had gone thru some posts on dynamic table creation,but could'nt find any on the dynamic field creation.
    Any suggestions pls?
    Thanks
    Nara

    I don't understand ...
    something like that ?
    *   Form P_MODIFY_HEADER.                                              *
    form p_modify_header.
      data : is_fieldcatalog type lvc_s_fcat ,
             v_count(2)      type n ,
             v_date          type d ,
             v_buff(30).
    * Update the fieldcatalog.
      loop at it_fieldcatalog into is_fieldcatalog.
        check is_fieldcatalog-fieldname+0(3) eq 'ABS' or
              is_fieldcatalog-fieldname+0(3) eq 'VAL' .
        move : is_fieldcatalog-fieldname+3(2) to v_count ,
               p_perb2+5(2)                   to v_date+4(2) ,
               p_perb2+0(4)                   to v_date+0(4) ,
               '01'                           to v_date+6(2) .
        v_count = v_count - 1.
        call function 'RE_ADD_MONTH_TO_DATE'
            exporting
              months        = v_count
              olddate       = v_date
            importing
              newdate       = v_date.
        if is_fieldcatalog-fieldname+0(3) eq 'ABS'.
          concatenate 'Quantité 0'
                      v_date+4(2)
                      v_date+0(4)
                      into v_buff.
        else.
          concatenate 'Montant 0'
                      v_date+4(2)
                      v_date+0(4)
                      into v_buff.
        endif.
        move : v_buff to is_fieldcatalog-scrtext_s ,
               v_buff to is_fieldcatalog-scrtext_m ,
               v_buff to is_fieldcatalog-scrtext_l ,
               v_buff to is_fieldcatalog-reptext .
        modify it_fieldcatalog from is_fieldcatalog.
      endloop.
    * Modify the fieldcatalog.
      call method obj_grid->set_frontend_fieldcatalog
           exporting it_fieldcatalog = it_fieldcatalog.
    * Refresh the display of the grid.
      call method obj_grid->refresh_table_display.
    endform.                     " P_MODIFY_HEADER

  • Adding a column in an internal table

    Hi,
    I want to know how to add different rows of a  column in an internal table.
    My code :
    Declaration Part-----
    types : begin of imchb,
            clabs like mchb-clabs,
            cumlm like mchb-cumlm,
            cinsm like mchb-cinsm,
            tot_val_stock type p decimals 3,
            pm_percent type p decimals 6,
            end of imchb.
    data : int_inv type standard table of imchb with header line,
           wa_inv like line of int_inv.
    Then I do few calculations and display it in the column pm_percent.
    Now I want to sum this column.
    Summation---
    loop
    at int_inv into wa_inv.
    at end of pm_percent.
    sum.
    endat.
    endloop.
    write :/ wa_inv-pm_percent.
    However , wa_inv-pm_percent only gives me the value of the last row of the column.
    Kindly suggest .

    Hi,
    Please try this code:
    loop at int_inv into wa_inv.
        lv_count = lv_count + 1.
        AT END OF posnr.   <------- The field you want to sum..
          gs_total-posnr      = wa_inv-posnr.
          gs_total-cov_total  = lv_count.
          APPEND gs_total TO gt_total.
          CLEAR : gs_total,
                  lv_count,
                  wa_inv.
        ENDAT.
      ENDLOOP.

  • Dynamic internal table column issue

    Hi
    i have ALV report with dynamic internal table.after i build the internal table and fieldcatalog i have problem  i.e. when grid is displayed then one of the column value is coming in the next column.i populated col_pos in field catalog also and in the debug mode data is populated correctly for respective columns in fieldcatalog and dynamic internal table. But when it is displayed i have this problem.
    any inputs on this?

    Hi Moorthy,
    Did you perform an ALV consistency check?
           Check the below given links as well.
    The Consistency Check - ALV Grid Control (BC-SRV-ALV) - SAP Library
    SAP ALV Consistency Check
    Regards,
    Philip.

Maybe you are looking for

  • How to Install Photoshop CC on a Drive Other than C:

    I have purchase and installed Photoshop CC on one of my computers. I'm now ready to install it on the second one. But this Win 7 PC is running short of space on its C: drive. I want to install the files onto its D: drive. But the installer does not a

  • Exception handling in integration processes

    Hi, I have a very simple question but I can't find an answer. I have designed an integration process that upon several other things send synchroneously a message to an ABAP proxy. Sometime the ABAP proxy generates exception. In my integration process

  • Message structure

    Hi all, In my application,client sends alarm message to server through web services and server sends the acknowledgement .I want to know that the following method at the server is ok or i should add something more to make it more real. public String

  • Cant get rules to work with pz:div tag

    im using commerce server 2.0.1 with sp1 i made a rule sheet and rule and rule selectors through the wlpsadmin tool and then i was trying to base content inside a portal using one of the rule selectors and the pz:div tag. this is what the jsp page has

  • How to add some extra parameter in SAP instance profile

    Dear Gurus, I want to add login/min_password_lng and login/fails_to_user_lock in my instance profile.Please guide me the steps how I can add this by using RZ10 T.Code so that it takes changes in program RSPARAM.In our scenario we have 1 CI server and