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 Field Catalog Help

Former Member
0 Kudos

Hi friends,

I am trying create a field catalog with FM for my internal table. I know I must use "Like" for my internal fields. But I have same field types in my internal. If I use like this. I cann't create field catalog with catalog merge ( I must use this FM for hide/show columns -my prev. message-)

What is your recommend to me for definiton of my internal table. How can create field catalog using REUSE_ALV_FIELDCATALOG_MERGE FM.

My internal table is :

Types : Begin Of TRapor,
          Renk,            "Satır Rengi
          Bilesen_Kodu     Like Mseg-Matnr,   "Malzeme Numarası
          Tanim            Like Makt-Maktx,   "Malzeme Kısa Metni
          Batch            Like Mseg-Charg,   "Parti Numarası - Batch
          Birim            Like Mseg-Meins,   "Temel ölçü birimi
          Malzeme_Fire(12) Type P Decimals 2, "Teorik Malzeme Fire % si
          Batch_Fire(12)   Type P Decimals 2, "Teorik Batch Fire % si
          OMiktar          Like Mseg-Menge,   "Önceki Dönem Miktar
          OYuzde(12)       Type P Decimals 2, "Önceki Dönem Yuzde
          OTeorik          Like Mseg-Menge,   "Önceki Dönem Teorik
          OSapma_Deger     Like Mseg-Menge,   "Önceki Dönem Sapma Değeri
          OSapma_Oran(12)  Type P Decimals 2, "Önceki Dönem Sapma Oranı
          SMiktar          Like Mseg-Menge,   "Seçim Dönemi Miktar
          SYuzde(16)       Type P Decimals 2, "Seçim Dönemi Yüzde
          STeorik          Like Mseg-Menge,   "Seçim Dönemi Teorik
          SSapma_Deger     Like Mseg-Menge,   "Seçim Dönemi Sapma Değeri
          SSapma_Oran(12)  Type P Decimals 2, "Seçim Dönemi Sapma Oranı
          Hareket          Like Mseg-Bwart,
          Isyeri           Like Crhd-Arbpl,
        End Of TRapor.

Data : IRapor Type Standard Table Of TRapor With Header Line.

6 REPLIES 6

Former Member
0 Kudos

Hi mehmet,

1. For those fields, which are

not LIKE,

2. First use the merge function.

3. then loop at the field catalogue,

at that paritcular fieldname,

and modify the TEXT, length etc of the row.

4. like this.

REPORT abc.

TYPE-POOLS : slis.

DATA : alvfc TYPE slis_t_fieldcat_alv.

DATA : fcl TYPE slis_fieldcat_alv.

*----


LOOP AT alvfc INTO fcl WHERE fieldname = 'XXX'.

fcl-ddictxt = 'L'.

fcl-seltext_l = 'Heading'.

fcl-outputlen = 15.

MODIFY alvfc FROM fcl.

ENDLOOP.

5. Setting only these 3 properties,

will be sufficient for the time being.

L = 'Long text'

regards,

amit m.

Message was edited by: Amit Mittal

former_member188685
Active Contributor
0 Kudos

hi,

use like,

data: begin of itab occurs 0,

vbeln like ...

posnr like...

end of itab.

and if you don't want to change then you need build manually....

if you use like then you can use

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = sy-repid

I_INTERNAL_TABNAME = 'ITAB'

I_INCLNAME = sy-repid

CHANGING

CT_FIELDCAT = it_fieldcat

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

regards

vijay

hymavathi_oruganti
Active Contributor
0 Kudos

i dont think, we should not use LIKE for using this fn module. it works fine.

r u getting any error? what is that?

0 Kudos

:((( It dowsn't work. What is wrong :((( I give NO_FIELDCATALOG_AVAILABLE error. When I debugging After processing merge FM my alvfc is empty (0x172)

Type-Pools : Slis.
Tables : Mseg, S226, Mara, Mkpf, Crhd, Plpo, Mkal.
Types : Begin Of TRapor,
          Renk(4)          Type C,            "Sat&#305;r Rengi
          Bilesen_Kodu     Like Mseg-Matnr,   "Malzeme Numaras&#305;
          Tanim            Like Makt-Maktx,   "Malzeme K&#305;sa Metni
          Batch            Like Mseg-Charg,   "Parti Numaras&#305; - Batch
          Birim            Like Mseg-Meins,   "Temel ölçü birimi
          Malzeme_Fire(12) Type P Decimals 2, "Teorik Malzeme Fire % si
          Batch_Fire(12)   Type P Decimals 2, "Teorik Batch Fire % si
          OMiktar          Like Mseg-Menge,   "Önceki Dönem Miktar
          OYuzde(12)       Type P Decimals 2, "Önceki Dönem Yuzde
          OTeorik          Like Mseg-Menge,   "Önceki Dönem Teorik
          OSapma_Deger     Like Mseg-Menge,   "Önceki Dönem Sapma De&#287;eri
          OSapma_Oran(12)  Type P Decimals 2, "Önceki Dönem Sapma Oran&#305;
          SMiktar          Like Mseg-Menge,   "Seçim Dönemi Miktar
          SYuzde(16)       Type P Decimals 2, "Seçim Dönemi Yüzde
          STeorik          Like Mseg-Menge,   "Seçim Dönemi Teorik
          SSapma_Deger     Like Mseg-Menge,   "Seçim Dönemi Sapma De&#287;eri
          SSapma_Oran(12)  Type P Decimals 2, "Seçim Dönemi Sapma Oran&#305;
          Hareket          Like Mseg-Bwart,
          Isyeri           Like Crhd-Arbpl,
        End Of TRapor.

*Data : IRapor Type Table Of TRapor With Header Line.
Data : IRapor Type Standard Table Of TRapor With Header Line.
Data : ZRapor Type TRapor Occurs 0 With Header Line.
.....
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : alvwa TYPE slis_fieldcat_alv.
...
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ZRAPOR'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*---------------Display

LOOP AT alvfc INTO alvwa WHERE fieldname = 'BILESEN_KODU'.

alvwa-ddictxt = 'L'.
alvwa-seltext_l = 'Heading'.
alvwa-outputlen = 15.


MODIFY alvfc FROM alvwa.
ENDLOOP.


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = alvfc
i_callback_program = sy-repid
i_callback_user_command = 'ITAB_USER_COMMAND'
TABLES
t_outtab = zrapor
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM.                    " Gecici

*------------------------------
FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE
slis_selfield.



LOOP AT alvfc INTO alvwa.

IF alvwa-fieldname = 'BUTXT'.
if alvwa-no_out = 'X'.
  alvwa-no_out = ''.
else.
  alvwa-no_out = 'X'.
endif.
*alvwa-no_out = 'X'.
MODIFY alvfc FROM alvwa.
ENDIF.

ENDLOOP.

*------- Field Catalogue
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ZRAPOR'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.




*---------------Display


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = alvfc
i_callback_program = sy-repid
i_callback_user_command = 'ITAB_USER_COMMAND'
TABLES
t_outtab = zrapor
EXCEPTIONS
program_error = 1
OTHERS = 2.



*----------- IMPORTANT.
*----------- IMPORTANT.

whatrow-exit = 'X'.




ENDFORM. "itab_user_command

0 Kudos

THERE IS SOME PROBLEM WITH THIS FN MODULE, U SHOULD BE VERY CAREFULL WHILE WORKING WITH THIS.

u should give the internal table name / structure namein the fn module as it is means even the CAPITAL/SMALL letters will matter.

try giving exactly.

u first delete it and call again and pass parameters carefully

0 Kudos

Hi Mehemt,

it won't give you , that is for sure.

until unless if you give <b>like</b> in your declarations, and

the internal table should be

<b>data: begin of itab occurs 0,

end of itab.</b>

if you want the fieldcat then manually build it.

regards

vijay