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: 

ALV help

Former Member
0 Kudos
126

Hi all,

I have 3 fields LMNGA , XMNGA, GRUND in internal table itab.

My condition is

1) if itab-xmnga is not initial and itab-grund = 1

and then i should get only XMNGA in my fieldcatalogue automatically

else.

2) I should get only LMNGA in my fieldcatalogue

but not both.

Please kindly help me.

I have the following code.


*&---------------------------------------------------------------------*
*&      Form  alv_init
*&---------------------------------------------------------------------*
FORM alv_init.
  alv_layout-max_linesize = 1023.
  alv_repid               = sy-repid.
  REFRESH:
    alv_fieldcat,
    alv_groups.

  PERFORM fill_fieldcat_manuell USING:
   'ITAB' 'PERNR' '' 'AFRU' 'PERNR' '' '' '',
   'ITAB' 'MATNR' 'Material' '' '' '10' '10' '',
   'ITAB' 'MAKTX' '' 'MAKT' 'MAKTX' '' '' '',
   'ITAB' 'AUFNR' '' 'AUFK' 'AUFNR' '' '' '',
   'ITAB' 'VORNR' '' 'AFVC' 'VORNR' '' '' '',
   'ITAB' 'ARBPL' '' 'CRHD' 'ARBPL' '' '' '',
   'ITAB' 'RUECK' '' 'AFRU' 'RUECK' '' '' '',
   'ITAB' 'BUDAT' '' 'AFRU' 'BUDAT' '' '' '',
   'ITAB' 'ERSDA' '' 'AFRU' 'ERSDA' '' '' '',
   'ITAB' 'KOSTL' '' 'CRCO' 'KOSTL' '' '' '',
   'ITAB' 'BMSCH' '' 'AFVV' 'BMSCH' '' '' '',
   'ITAB' 'LMNGA' 'Menge(Stck)' '' '' '20' '20' 'X',-->if 
Condition 2
   'ITAB' 'XMNGA' 'Menge' '' '' '20' '20' 'X',--> If condition 1.
   'ITAB' 'VGW03' 'tr' '' '' '20' '20' '',
   'ITAB' 'VGW04' 'te' '' '' '20' '20' '',
   'ITAB' 'VGW01' 'trb' '' '' '20' '20' '',
   'ITAB' 'VGW02' 'teb' '' '' '20' '20' '',
*   'ITAB' 'MZEIT' 'Maschienenzeit' '' '' '20' '20' '',
   'ITAB' 'PZEIT1' 'plan tr h' '' '' '20' '20' 'X',
   'ITAB' 'PZEIT2' 'plan te h' '' '' '20' '20' 'X',
   'ITAB' 'MZEIT1' 'plan trb h' '' '' '20' '20' 'X',
   'ITAB' 'MZEIT2' 'plan teb h' '' '' '20' '20' 'X',
   'ITAB' 'ISM03' 'ist tr h' '' '' '20' '20' 'X',
   'ITAB' 'ISM04' 'ist te h' '' '' '20' '20' 'X',
   'ITAB' 'ISM01' 'ist trb h' '' '' '20' '20' 'X',
   'ITAB' 'ISM02' 'ist teb h' '' '' '20' '20' 'X'.
*   'ITAB' 'PZEIT2' 'Ist.Personal' '' '' '20' '20' 'X',
*   'ITAB' 'MZEIT2' 'Ist.Maschienen' '' '' '20' '20' 'X'.




ENDFORM.

*&---------------------------------------------------------------------*
*&      Form  FILL_FIELDCAT_MANUELL
*&---------------------------------------------------------------------*
FORM fill_fieldcat_manuell USING tab    field    text
                                 reftab reffield
                                 len_i  len_o sum.

  CLEAR alv_fieldcat.

  alv_fieldcat-ref_tabname    = reftab.
  alv_fieldcat-ref_fieldname  = reffield.
  alv_fieldcat-reptext_ddic   = text.
  alv_fieldcat-seltext_l      = text.
  alv_fieldcat-seltext_m      = text.
*  alv_fieldcat-seltext_s      = text.
  alv_fieldcat-ddic_outputlen = len_o.
  alv_fieldcat-intlen         = len_i.
  alv_fieldcat-fieldname      = field.
  alv_fieldcat-tabname        = tab.
  alv_fieldcat-do_sum         = sum.


  APPEND alv_fieldcat.
ENDFORM.                    " FILL_FIELDCAT_MANUELL

Thanks and regards

Chandu.

Message was edited by: Sai Chand Pullepu

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
96

Not sure what you are trying to do here, but you cannot change your field catalog depending on one line of an internal table. Or multiple lines of an internal table, That doesn't make much sence, right?

Your field catalog must defined by some conditions at a higher level.

Or do you just want to base the field catalog on the first record of your internal table?

Regards,

Rich Heilman

4 REPLIES 4

former_member188685
Active Contributor
0 Kudos
96

Hi Sai,

itab is not single record, it is holding so many records.

if the data changes then how can it be possible.

is the data in xmnga,grund is constant (either they hold data, and grund = 1 or they don't) then you can find using if condition.

if not itab-xmnga is initial and itab-grund = 1.
populate fieldcat for XMNGA 
esle.
populate fieldcat for LMNGA 
endif.

if they hold two conditions then it is difficult.

Regards

Vijay

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
97

Not sure what you are trying to do here, but you cannot change your field catalog depending on one line of an internal table. Or multiple lines of an internal table, That doesn't make much sence, right?

Your field catalog must defined by some conditions at a higher level.

Or do you just want to base the field catalog on the first record of your internal table?

Regards,

Rich Heilman

0 Kudos
96

Hi,

For ex.

In itab i have the following data

LMNGA XMNGA GRUND

3 5 -> condition not satisfeid then i should only display LMNGA in the output list

4 4 1 -> Condition satisfeid then i should only display XMNGA in the output list

5 -> again not satisfeid then i should only display LMNGA in the output list.

My question is is it possible to do it based on some conditions in Filedcat .

I hope its clear

regards

chandu.

Message was edited by: Sai Chand Pullepu

0 Kudos
96

Hi Sai Chand,

No it canot be done as you want.

but it can be done in normal way.

LMNGA XMNGA

3

4

5

like this , for this you need not do any thing, you know this.

but columns and rows should coordinate for your requirement.

Regards

Vijay