Skip to Content
author's profile photo Former Member
Former Member

RELATED TO ALV GRID

hi all,

In alv reports which r done using object oriented concepts, im able to print all the fields

of a table by passing LFA1 table to the parameter I_STRUCTUE_NAME of method

SET TABLEFOR_FIRST_DISPLAY and IT_OUTTAB as ITAB.

I declared ITAB as...DATA:ITAB TYPE TABLE OF VBAK .

Now, the problem is...if i want to declare my ITAB with only few fields then wat is the method i have to use to display and wat r the parameters i have to pass...so that my output will have only the columns i declared and not the whole structure of LFA1.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Jun 08, 2007 at 01:08 PM

    You have to define a filed catalog and remove the entries from the field catalog:

    http://help.sap.com/saphelp_webas630/helpdata/en/22/a3f5fed2fe11d2b467006094192fe3/frameset.htm

    Best regards,

    Peter

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 08, 2007 at 01:11 PM

    Hello Aturi

    Do not create the fieldcatalog manually but use the function module LVC_FIELDCATALOG_MERGE.

    If you need only a few fields out of a structure you could use the following coding:

    DATA:
      gs_fcat   TYPE lvc_s_fcat,
      gt_fcat    TYPE lvc_t_fcat.
    
    
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'LFA1'
        CHANGING
          ct_fieldcat           = gt_fcat.
          
      gs_fcat-no_out = 'X'.  " column is visible neither on ALV list nor in the layout
      MODIFY gt_fcat FROM gs_fcat
        TRANSPORTING FIELD no_out
      WHERE ( no_out ne 'X' ).
    
    " Make all required columns visible again...
      LOOP AT gt_fcat INTO gs_fcat
                                WHERE ( fieldname = 'required column'    AND
                                               fieldname = ... ).
        gs_fcat-no_out = ' '.
        MODIFY gt_fcat FROM gs_fcat.
      ENDLOOP.

    If you need fields from different tables you can repeatedly call the function module and use the logic above. To distinguish between fields of different tables simply add:

      LOOP AT gt_fcat INTO gs_fcat
                                WHERE ( ref_table = 'LFA1' )
                                AND      ( fieldname = ... ).
    ...
      ENDLOOP.

    Regards

    Zwe

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 08, 2007 at 01:19 PM

    Hi,

    You need to create which are the fields your want to display and pass it in set_table_for_first_display and remove the parameter I_STRUCTUE_NAME

    
      ls_fcat-fieldname = 'MATNR' .
      ls_fcat-ref_table = 'MARA' .
      ls_fcat-outputlen = '16'.
      ls_fcat-col_opt   = 'X'.
      append ls_fcat to i_fieldcat.
      clear ls_fcat.
    *
      ls_fcat-fieldname = 'WERKS' .
      ls_fcat-ref_table = 'T001W' .
      append ls_fcat to pt_fieldcat.
      clear ls_fcat.
    
        call method grid1->set_table_for_first_display
          exporting
            is_layout                     = gs_layout
          changing
            it_outtab                     = i_output[]
            it_fieldcatalog               = i_fieldcat[]
          exceptions
            invalid_parameter_combination = 1
            program_error                 = 2
            too_many_lines                = 3
            others                        = 4.
    
    

    aRs

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.