Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

pls help

Former Member
0 Likes
301

hi all

i have a problem. can this be solved?

i have period in months as a select option(s012-spmon) . there are some other selection criteria, based on which the dat comes. the spmon sel option has validation for 4 months say mar to jun in the output display we need 4 columns for quantity and price fields corresponding to these 4 months. if we enter mar to may

then the data shud be displayed in the corresponding fields ie the col 1 and 2 shud be poulated else if select months 2-4 then the corresponding columns shud be poulated for quantuty and price .

how to get this ?

i ahve written the code for single field for quantity and price, but how can the above prblm be solved

can anyone help pls

thanks in advance

1 REPLY 1
Read only

Former Member
0 Likes
280

Hi,

You have to create a dynamic internal table..

Check this example..

If you give the input as 3...IT will create 3 columns..

PARAMETERS: p_input TYPE i OBLIGATORY.

START-OF-SELECTION.

DATA: v_fieldname TYPE char30.

DATA: v_char TYPE numc4.

DATA: it_fldcat TYPE lvc_t_fcat.

DATA: wa_it_fldcat LIKE LINE OF it_fldcat.

DATA: gp_table TYPE REF TO data.

FIELD-SYMBOLS: <gt_table> TYPE table.

DO p_input TIMES.

v_fieldname = 'COL'.

v_char = sy-index.

CONCATENATE v_fieldname v_char INTO v_fieldname.

CONDENSE v_fieldname.

CLEAR wa_it_fldcat.

wa_it_fldcat-fieldname = v_fieldname.

wa_it_fldcat-datatype = 'CHAR'.

wa_it_fldcat-outputlen = 5.

wa_it_fldcat-intlen = 5.

APPEND wa_it_fldcat TO it_fldcat .

ENDDO.

  • Internal table creation..

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING it_fieldcatalog = it_fldcat

IMPORTING ep_table = gp_table.

ASSIGN gp_table->* TO <gt_table>.

CHECK sy-subrc = 0.

DATA: WA TYPE REF TO DATA.

  • Work area for the dynamic internal table.

CREATE DATA WA LIKE LINE OF <gt_table>.

WRITE: / 'Dynamic internal table created'.

Thanks,

Naren