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

SAP Query.

former_member556412
Active Participant
0 Likes
1,005

Hi,

My requirement is....

I have a query with few selection screen parameters.

say column1

column2

column3

column4

if in column 1 some value is entered then only first column should be displayed.

or if column1 and column2 is selected then only these two columns should be displayed.

How can i achieve this.

Any help will be appreciated.

Regards,

Bhanu

8 REPLIES 8
Read only

Former Member
0 Likes
974

Hi Nand

i think you are refering to creation of a dynamic internal table. If yes, then after your field catalogue is created then:

Loop at the range at the selection screen or if requires, do the necessary validations/manipulation, and store values at another internal table. For example, we are looping here at the internal table so as to provide the headings at the respective columns dynamically.

LOOP AT tb_dynamic_range.

wa_fieldcat-col_pos = lv_column_pos.

wa_fieldcat-fieldname = tb_dynamic_range-

<Field; containing the name>.

wa_fieldcat-seltext_l = wa_fieldcat-seltext_m

= wa_fieldcat-seltext_s

= tb_dynamic_range-

<Field; containing the name>.

wa_fieldcat-outputlen = u201810u2019.

APPEND wa_fieldcat TO tb_fieldcat.

CLEAR wa_fieldcat.

lv_column_pos = lv_column_pos + 1.

ENDLOOP.

Here, it has been considered that all the dynamic columns corresponding to one line item at tb_output can be shown at the last of all the rest columns.This can be changed if need persists.

*Generate the Dynamic internal table with the relevant fields prepared.

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = tb_fields_for_it

IMPORTING

ep_table = gp_dyn_table.

*Assign a pointer to the Dynamic internal table

ASSIGN gp_dyn_table->* TO <gt_table>.

ASSIGN LOCAL COPY OF INITIAL LINE OF <gt_table> TO <fs_table>.

  • Filling the dynamic table with the values obtained at the output table

LOOP AT tb_output .

lv_index = co_1.

ASSIGN COMPONENT lv_index OF STRUCTURE <fs_table>

TO <ls_field>.

<ls_field> = tb_output-field1.

ADD co_1 TO lv_index.

ASSIGN COMPONENT lv_index OF STRUCTURE <fs_table>

TO <ls_field>.

<ls_field> = tb_output-field2.

ADD co_1 TO lv_index.

And so on for the other remaining fieldsu2026u2026

Its a bit tedious, but will surely help you.

Harsh

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
974

Plz use proper subjects for ur threads ...

have a query with few selection screen parameters.

column1

column2

column3

column4

How are these two related...

Ur qn is not clear

Read only

0 Likes
974

I have a selection screen.

In which i have 4 parameters.

Column I ..................Input field

Column II ...................Input field

Column III ...................Input field

Column IV ..................Input field

Above 4 Columns should be displayed dynamically

Ex., If user enters Column I and Column II then the output should have only entered columns.

I hope its clear Now.

regards,

Bhanu

Read only

0 Likes
974

check colomn1 is initial.

check colomn2 is initial.

then build ur logic.

Read only

0 Likes
974

Have done the same .

But not getting the expected result.

Regards,

Bhanu

Read only

0 Likes
974

Hi,

You can either build your logic by checking for the column is initial and then writing the logic below it, or else you can do all you selections and finally while building your field catalogue just check is the parameter is initial. If yes then hide or restrict that column data from appearing in the output by using the parameter NO-OUT = 'X'. This would make sure that the coulmns where the value is not eneterd will not appear in the output.

Thanks,

Vikas.

Read only

0 Likes
974

paste ur code

Read only

former_member556412
Active Participant
0 Likes
974

This requirement was getting much complex so have done it using Reports.