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: 

How can I set ALV Grid Row Color when I use REUSE_ALV_FIELDCATALOG_MERGE

Former Member
0 Kudos

Hi friends

I am trying display my some special rows colorized. I search on SDN but I cann't find a solution for my situation.

So when I try display my SRAPOR internal table i didn't see anything in my ALV. When I debugging I can see all data in SRAPOR. But after catalog merge I see only Renk field in my ALVcatalog. When I add my other fields in catalog manually (in debug mode) I can see rows with colorized.

How can I define my SRapor structure for best result? Why catalog merge doesn't add my included fields in catalog list?

Thanks

Mehmet

REPORT  zhyt_pp_rpr_288.
*&---------------------------------------------------------------------*
*&      Tanımlamalar
*&---------------------------------------------------------------------*

Type-Pools : Slis.
Tables     : Mseg, S226, Mara, Mkpf, Crhd, Plpo, Mkal, Makt.
DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
      FIELDCAT type SLIS_FIELDCAT_ALV,
      L_layout type SLIS_LAYOUT_ALV,
      EMatnr Like Makt-Matnr,
      p_show.
Data : Begin Of IRapor Occurs 0,
          Bilesen_Kodu     Like Makt-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 IRapor.
Data : Wa_Rapor  Like Line Of IRapor,
       Wa_YRapor Like Line Of IRapor,
       XRapor    Like IRapor Occurs 0 With Header Line,
       YRapor    Like IRapor Occurs 0 With Header Line.

Data : Begin Of SRapor Occurs 0,
         Renk(4).
         Include Structure IRapor.
Data : End Of SRapor.

*&---------------------------------------------------------------------*
*&      Selection Screens
*&---------------------------------------------------------------------*

..............

*&---------------------------------------------------------------------*
*&      Process Adımları
*&---------------------------------------------------------------------*

perform GenerateData.
perform BuildCatalog.
perform BuildLayout.
perform ShowData.

*&---------------------------------------------------------------------*
*&      Form  GenerateData
*&---------------------------------------------------------------------*
FORM GenerateData .
................
Loop At XRapor Into wa_rapor.
  SRapor-Renk = 'C210'.
  if EMatnr <> wa_rapor-Bilesen_Kodu.
    if EMAtnr <> ''.
      Loop At YRapor Into wa_yrapor Where Bilesen_Kodu = EMAtnr.
         SRapor-Renk = 'C610'.
         Move-Corresponding Wa_YRapor To SRapor.
         Append SRapor.
      Endloop.
    endif.
   EMatnr = wa_rapor-Bilesen_Kodu.
  endif.
  clear wa_rapor-tanim.
  Move-Corresponding Wa_Rapor To SRapor.
  Append SRapor.
Endloop.
ENDFORM.                    " GenerateData

*&---------------------------------------------------------------------*
*&      Form  BuildCatalog
*&---------------------------------------------------------------------*
FORM BuildCatalog .

  Call Function 'REUSE_ALV_FIELDCATALOG_MERGE'
    Exporting
      I_Program_Name         = Sy-Repid
      I_Internal_Tabname     = 'IRAPOR'
      I_Inclname             = Sy-Repid
    Changing
      Ct_Fieldcat            = Gt_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.


ENDFORM.                    " BuildCatalog

*&---------------------------------------------------------------------*
*&      Form  ShowData
*&---------------------------------------------------------------------*
FORM ShowData .

  Call Function 'REUSE_ALV_GRID_DISPLAY'
    Exporting
      Is_Layout                = L_Layout
      I_Callback_Program       = Sy-Repid
      I_Callback_Pf_Status_Set = 'STATUS'
      I_Callback_User_Command  = 'USER_COMMAND'
      It_Fieldcat              = Gt_Fieldcat[]
    Tables
      T_Outtab                 = IRAPOR.

ENDFORM.                    " ShowData

*&--------------------------------------------------------------------*
*&      Form  Status
*&--------------------------------------------------------------------*
FORM STATUS USING P_EXTAB TYPE SLIS_T_EXTAB  .
  SET pf-status 'STANDARD' excluding p_extab.
ENDFORM.                    "status

*&--------------------------------------------------------------------*
*&      Form  User Command
*&--------------------------------------------------------------------*
FORM USER_COMMAND USING P_UCOMM LIKE SY-UCOMM P_SELFIELD TYPE
SLIS_SELFIELD.
  CASE p_ucomm.
    when 'TEST'.
        if p_show = 'X'.
           p_show = ''.
        else.
          p_show = 'X'.
        endif.
        fieldcat-no_out = p_show.
        modify gt_fieldcat from fieldcat
               transporting no_out where fieldname = 'TANIM'.

    p_selfield-exit = 'X'.
    PERFORM ShowData.
    ENDCASE.
 ENDFORM.                    "USER_COMMAND
*&---------------------------------------------------------------------*
*&      Form  BuildLayout
*&---------------------------------------------------------------------*
FORM BuildLayout .
* L_Layout-zebra             = 'X'.
 L_Layout-Info_Fieldname    = 'RENK'.
 L_Layout-Colwidth_Optimize = 'X'.
ENDFORM.                    " BuildLayout

4 REPLIES 4

former_member188685
Active Contributor
0 Kudos

Hi,

you need to modify the fieldcat after calling the FM.

loop at it_fieldcat into x_fieldcat.
if x_fieldcat-fieldname = 'VBELN'.
x_fieldcat-emphasize = 'C400'.
modify it_fieldcat from x_fieldcat index sy-tabix.
endif.
endloop.

this will modify the color of whole column...

regards

vijay

0 Kudos

Dear Vijay,

I try your suggestion but Catalog can see fields but don't add result catalog. After that I manually add catalog fields in my Gt_Fieldcat. Now it is working. Thanks for your quick and helpful answer.

Regards

Mehmet

0 Kudos

Ok, any way your Proble solved .

Good luck.

Regards

vijay

Former Member
0 Kudos

This message was moderated.