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

"Collect" in dynamic table.

COLLECT <dyn_wa> INTO <dyn_table> is not adding the numeric data field types.

Where am I wrong?

I have created the dynamic table as shown in the FORM routine:

I have declared the fields to be added as follows:

wa_it_fldcat-datatype = 'INT'.

Is this right?

FORM build_dyn_itab.

DATA: new_table TYPE REF TO data,

new_line TYPE REF TO data,

wa_it_fldcat TYPE lvc_s_fcat.

CLEAR wa_it_fldcat.

wa_it_fldcat-fieldname = 'VENDOR'.

wa_it_fldcat-datatype = 'CHAR'.

wa_it_fldcat-intlen = 10.

wa_it_fldcat-outputlen = 10.

APPEND wa_it_fldcat TO it_fldcat .

CLEAR wa_it_fldcat.

wa_it_fldcat-fieldname = 'USERID'.

wa_it_fldcat-datatype = 'CHAR'.

wa_it_fldcat-intlen = 10.

wa_it_fldcat-outputlen = 10.

APPEND wa_it_fldcat TO it_fldcat .

CLEAR wa_it_fldcat.

wa_it_fldcat-fieldname = 'CO_CODE'.

wa_it_fldcat-datatype = 'CHAR'.

wa_it_fldcat-intlen = 5.

wa_it_fldcat-outputlen = 5.

APPEND wa_it_fldcat TO it_fldcat .

SORT ispbup BY spbup ASCENDING.

LOOP AT ispbup.

CLEAR wa_it_fldcat.

ind = sy-tabix.

wa_it_fldcat-fieldname = ispbup-spbup.

  • concatenate 'PERIOD' ind into wa_it_fldcat-fieldname.

wa_it_fldcat-fieldname = ispbup-spbup.

CONDENSE wa_it_fldcat-fieldname NO-GAPS.

  • wa_it_fldcat-REPTEXT = ispbup-spbup.

wa_it_fldcat-datatype = 'INT'.

wa_it_fldcat-outputlen = 6.

wa_it_fldcat-intlen = 6.

APPEND wa_it_fldcat TO it_fldcat .

ENDLOOP.

CLEAR wa_it_fldcat.

wa_it_fldcat-fieldname = 'TOTAL'.

wa_it_fldcat-datatype = 'INT'.

wa_it_fldcat-outputlen = 7.

wa_it_fldcat-intlen = 7.

APPEND wa_it_fldcat TO it_fldcat .

  • Create dynamic internal table and assign to FS

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = it_fldcat

IMPORTING

ep_table = new_table.

ASSIGN new_table->* TO <dyn_table>.

  • Create dynamic work area and assign to FS

CREATE DATA new_line LIKE LINE OF <dyn_table>.

ASSIGN new_line->* TO <dyn_wa>.

ENDFORM. " build_dyn_itab

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2007 at 04:13 PM

    Hi

    Are you sure the type INT is defined?

    The integer type should be INT1, INT2 and INT4:

    So try to do these modification:

    LOOP AT ispbup.
      ..............................
      wa_it_fldcat-datatype = 'INT4'. "<---------------
      .................................
      APPEND wa_it_fldcat TO it_fldcat .
    ENDLOOP.
    
    CLEAR wa_it_fldcat.
    wa_it_fldcat-fieldname = 'TOTAL'.
    wa_it_fldcat-datatype = 'INT4'. "<-----------------
    wa_it_fldcat-outputlen = 7.
    wa_it_fldcat-intlen = 7.
    APPEND wa_it_fldcat TO it_fldcat.

    INT4 should mean positive/negative integer numbers

    Max

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi

      U can dynamically sort the table using some variable to store the field/s for the sorting (not an internal table):

      *T_FIELD = 'VENDOR'.
      *APPEND T_FIELD.
      
      DATA: FIELD(30).
      
      FIELD = 'VENDOR'.
      
      SORT <DYN_TABLE> BY (FIELD) .

      U can sort for several fields:

      DATA: FIELD(30), FIELD1(30), FIELD2(30),....

      FIELD = 'VENDOR'.

      SORT <DYN_TABLE> BY (FIELD) (FIELD1) (FIELD2) ...(FIELDN) .[/code]

      Max

  • author's profile photo Former Member
    Former Member
    Posted on Jan 09, 2007 at 04:57 PM

    another question for the same program

    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.