Application Development 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: 

Dynamic ALV Table Ouput

Former Member
0 Kudos

Hi Experts,

I have one final table(assume it contains 25 fields) for final output in ALV report.

I've 5 different radiobuttons on my selection-screen.

Depending upon the radiobutton selected , user needs 5 different report outputs

from this one table.

I mean if he selected first radiobutton , he needs some 15 fields only to be displayed out of 25 fields.

Similarly if he select 3rd radiobutton then he needs some 10 fields only to be displayed out of 25 fields.

Is it possible to display the reuired fields only from my final table ?Otherwise I've create 5 more int.tables and move the contents depending upon the radibutton selected.

Please help me, point for sure..

Thanks,

Ponraj.s.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

U have to write some logical coding like.

suppose u have alv with five fields f1,f2...so on f5

if rb1(radio button 1) is selected then u want to display first three fields,

if rb2 is selected then u want to display last three fields

and if rb3 is selected then u want to display middle three fields of alv in display,

so u have to write ,

if rb2 = 'x' or rb3 = 'x'.

no_out = 'x' for the f1 field.

endif.

if rb3 = 'x'.

no_out = 'x' for f2

endif.

-


third field is displaying for all the radio button selection so if condition for it.

simply write the code for it.

-


if rb1 = 'x'.

no_out = 'x' for f4

endif.

if rb2 = 'x' or rb1 = 'x'.

no_out = 'x' for the f5 field.

endif.

I think this is helpful for u.

7 REPLIES 7

varma_narayana
Active Contributor
0 Kudos

Hi Ponraj.

There is no need to Create 5 internal Tables.

Declare the Final internal table with All the 25 fields.

Based on the Radio button selection you have to Hide some fields using the FIELD CATALOG attribute NO_OUT = 'X'.

<b>reward if Helpful</b>

0 Kudos

Hi Varma,

Thanks for your reply .

Tats okey, but in that case I've to code 5 different field catalog merge. I was thinking of writing only once.

I mean , if radiobutton 1 is selected then,

field catalog for first radiobutton.

if radiobutton 2 is selected then,

field catalog for second radiobutton.

It becomes lenghty coding?

Is it could be resolved in any other way?waiting for your reply.

Former Member
0 Kudos

U have to write some logical coding like.

suppose u have alv with five fields f1,f2...so on f5

if rb1(radio button 1) is selected then u want to display first three fields,

if rb2 is selected then u want to display last three fields

and if rb3 is selected then u want to display middle three fields of alv in display,

so u have to write ,

if rb2 = 'x' or rb3 = 'x'.

no_out = 'x' for the f1 field.

endif.

if rb3 = 'x'.

no_out = 'x' for f2

endif.

-


third field is displaying for all the radio button selection so if condition for it.

simply write the code for it.

-


if rb1 = 'x'.

no_out = 'x' for f4

endif.

if rb2 = 'x' or rb1 = 'x'.

no_out = 'x' for the f5 field.

endif.

I think this is helpful for u.

0 Kudos

Hi Dharmishta,

I agree what you are saying, this think i 've to do it in my field catalog, but i dont want this lenghty coding to be doen. since i've 25 fields and with 5 radiobutton it makes me to do 5 different field catalogs.

Something has to be doen dynamicall?Please think of it.

Waiting for your reply.

Thanks,

Ponraj.s.

0 Kudos

Pon,

FORM build_fieldcat .

IF itab[] IS INITIAL.

MESSAGE 'No Values exist for the Selection.' TYPE 'S'.

STOP.

ENDIF.

DEFINE m_fieldcat.

itfieldcat-fieldname = &1.

itfieldcat-col_pos = &2.

itfieldcat-seltext_l = &3.

itfieldcat-do_sum = &4.

itfieldcat-outputlen = &5.

append itfieldcat to itfieldcat.

clear itfieldcat.

END-OF-DEFINITION.

m_fieldcat 'LFBNR' '' 'GR NO' '' 10.

m_fieldcat 'BELNR' '' 'MIRO NO' '' 10.

m_fieldcat 'BUZEI' '' 'MIRO LN ITM' '' 10.

m_fieldcat 'LIFNR' '' 'VENDOR CODE' '' 10.

m_fieldcat 'NAME1' '' 'VENDOR NAME' '' 14.

m_fieldcat 'STR_SUPPL1' '' 'VENDOR ADDRESS' '' '15' .

m_fieldcat 'POST_CODE1' '' 'PINCODE' '' 6.

m_fieldcat 'XBLNR' '' 'VEN INV NO' '' 16.

m_fieldcat 'BLDAT' '' 'VEN INV DATE' '' 8.

m_fieldcat 'EBELN' '' 'PUR ORD NO' '' 10.

*Start of Insertion by Kiran.K to display PO Doc. Type dated 060707.

*m_fieldcat 'BSART' '' 'PUR ORD DOC.TYPE' '' 5. "Pur.Doc Type

m_fieldcat 'BATXT' '' 'PUR ORD DOC.TYPE' '' 20. "Pur Doc. Type Description

*End of Insertion by Kiran.K to display PO Doc. Type dated 060707

m_fieldcat 'EBELP' '' 'PUR LN ITM' '' 5.

m_fieldcat 'WERKS' '' 'PLANT' '' 8.

m_fieldcat 'MATNR' '' 'MAT NO' '' 18.

m_fieldcat 'MAKTX' '' 'MAT DESC' '' 15.

m_fieldcat 'MATKL' '' 'MAT CC' '' 7.

m_fieldcat 'MENGE' '' 'QTY' '' 13.

m_fieldcat 'WRBTR' '' 'VAL. OF GOODS' '' 11.

m_fieldcat 'WAERS' '' 'CURR' '' 5.

m_fieldcat 'INRVAL' '' 'INR VALUE' '' 13.

m_fieldcat 'BED' '' 'BED' '' 10.

m_fieldcat 'CVD' '' 'CVD' '' 10.

m_fieldcat 'ECVD' '' 'CESS ON CVD' '' 10.

m_fieldcat 'ECED' '' 'CESS ON DUTIES' '' 13.

*Bill of Lading Removed and Bill of Entry Added.

  • m_fieldcat 'FRBNR' '' 'BILL OF LADING' '' 13.

m_fieldcat 'BELNR1' '' 'BILL OF ENTRY' '' 13.

m_fieldcat 'REVERSE' '' 'Reversed' '' 2.

m_fieldcat 'FIDOC' '' 'FI DOC NO' '' 10.

m_fieldcat 'MWSKZ' '' 'TC' '' 2.

m_fieldcat 'BKLAS' '' 'VL CLS' '' 4.

m_fieldcat 'CITY1' '' 'VENDOR CITY' '' 10.

m_fieldcat 'QTR_MTH' '' 'MONTH' '' 10.

m_fieldcat 'QTR_YR' '' 'YEAR' '' 4.

m_fieldcat 'REMARKS' '' 'REMARKS' '' 15.

ENDFORM. " build_fieldcat

Define the fieldcatalog in the above said way,so that there won't be lengthy coding.

K.Kiran.

0 Kudos

Hello,

you will find a solution below.

you can create an internal table wt_not_out_fields. This internal table will have 6 fields :

1/fieldname,

2/radio_button_number_01 TYPE char01

3/radio_button_number_02 TYPE char01

...

6/radio_button_number_05 TYPE char01

How to fill the table :

fieldname : name of field of the alv table

radio_button_number_01 : 'X' if the field has to be hidden if the radio button 1 is on.

radio_button_number_02 : 'X' if the field has to be hidden if the radio button 2 is on.

etc...

How to use the table?

Sort and read the table to move 'X' to the FIELD CATALOG attribute NO_OUT.

Former Member
0 Kudos

One another thing u can do is,

Declare 5 diif internal table having fields

tablename,

fieldname

seltext

ok and fill the data into all the five tables according to your requirement of radiobutton selection,

now do the coding in this way,

if rb1='x'.

loop at it1.

wa_fcat-tabname = it1-tablename.

wa_fcat-fieldname = it1-fieldname.

wa_fcat-seltext_m = it1-seltext.

APPEND wa_fcat TO temp_fcat.

CLEAR wa_fcat.

endloop.

endif.

.

.

.

if rb5='x'.

loop at it5.

wa_fcat-tabname = it5-tablename.

wa_fcat-fieldname = it5-fieldname.

wa_fcat-seltext_m = it5-seltext.

APPEND wa_fcat TO temp_fcat.

CLEAR wa_fcat.

endloop.

endif.

I think this will definately help u.