Oops Alv Feild Catalog q & A

Embed Size (px)

Citation preview

  • 7/27/2019 Oops Alv Feild Catalog q & A

    1/9

  • 7/27/2019 Oops Alv Feild Catalog q & A

    2/9

    ENDLOOP.

    Outputlen: Changing the particular field output length.

    Determines the column width of the field:? If the field has a reference to the Data Dictionary, you can leave the field set to

    its initial value. In this case, the ALV adopts the output length of the relevant domain.

    ? For fields without reference to the DDIC, you must specify the desired fieldoutput length.LOOP AT i_fieldcat ASSIGNING .

    CASE -fieldname.

    when 'FULLTIMEEMPLOYEE'.-outputlen = '8'.

    ENDCASE.

    ENDLOOP.

    Key: Making a field as key field if set or non-key field if not set.If this field is set, the ALV Grid Control color-codes the column as a key field and fixes this

    column during horizontal scrolling. The order of the key columns in the ALV Grid Control can

    be modified interactively. In contrast to the SAP List Viewer, the ALV Grid Control allows youto directly hide key columns with NO_OUT.

    LOOP AT i_fieldcat ASSIGNING .

    CASE -fieldname.

    when 'ENO'.-key = ' '.

    ENDCASE.

    ENDLOOP.

    No_out: If you set this field, you hide the relevant column in the list. Nevertheless, the column is

    available in the field selection and can be interactively selected by the user as a display field. TheALV displays the contents of hidden fields on the detail screen for a row in the grid

    control.LOOP AT i_fieldcat ASSIGNING .

    CASE -fieldname.

    when 'AGE'.-no_out = 'X'.

    ENDCASE.

    ENDLOOP.In change layout, the user can select the column and then make the field to appear in output.

    Just: Relevant only to fields of data type CHARorNUMC. Justifications:

    ? 'R': right justified

    ? 'L': left justified? 'C': centered

    How the column header is justified, depends on how the column contents are justified. You

    cannot justify the column header separately.LOOP AT i_fieldcat ASSIGNING .

    CASE -fieldname.

    when 'AGE'.-just = 'R'.

    ENDCASE.

  • 7/27/2019 Oops Alv Feild Catalog q & A

    3/9

  • 7/27/2019 Oops Alv Feild Catalog q & A

    4/9

    Complete CodeScreen 9000, GUI Status ZSTATUS and GUI Title ZTITLE should be created and in Flow logicof the screen, PBO and PAI should be uncommented.

    REPORT zzz_jaytest message-id zz.

    * Data declarations

    DATA : itab TYPE STANDARD TABLE OF zzztable,"Output table

    i_fieldcat TYPE STANDARD TABLE OF lvc_s_fcat,"Field catalogwa TYPE zzztable,

    w_variant TYPE disvariant,

    o_docking TYPE REF TO cl_gui_docking_container,"Docking Containero_grid TYPE REF TO cl_gui_alv_grid."Grid

    FIELD-SYMBOLS : TYPE lvc_s_fcat.SELECT * FROM zzztable INTO TABLE itab.

    CALL SCREEN 9000.*&---------------------------------------------------------------------*

    *& Module STATUS_9000 OUTPUT

    *&---------------------------------------------------------------------** PBO

    *----------------------------------------------------------------------*

    MODULE status_9000 OUTPUT.

    IF o_docking IS INITIAL.SET PF-STATUS 'ZSTATUS'. "GUI Status

    SET TITLEBAR 'ZTITLE'. "Title

    * Creating Docking Container and grid

    PERFORM create_object.* Filling the fieldcatalog table

    PERFORM create_fieldcat.

    * Modifying the fieldcatalog table

  • 7/27/2019 Oops Alv Feild Catalog q & A

    5/9

    PERFORM modify_fieldcat.

    * Displaying the output

    PERFORM display_output.ENDIF.

    ENDMODULE. " STATUS_9000 OUTPUT

    *&---------------------------------------------------------------------**& Module USER_COMMAND_9000 INPUT*&---------------------------------------------------------------------*

    * PAI

    *----------------------------------------------------------------------*MODULE user_command_9000 INPUT.

    DATA lv_ucomm TYPE sy-ucomm.

    lv_ucomm = sy-ucomm.

    CASE lv_ucomm.WHEN 'CANCEl' OR 'EXIT'.

    PERFORM free_objects.

    LEAVE PROGRAM.WHEN 'BACK'.

    PERFORM free_objects.

    SET SCREEN '0'.

    LEAVE SCREEN.ENDCASE.

    ENDMODULE. " USER_COMMAND_9000 INPUT

    *&---------------------------------------------------------------------**& Form create_object

    *&---------------------------------------------------------------------*

    * Creating Docking Container and grid

    *----------------------------------------------------------------------*FORM create_object .

    * Creating Docking Container

    CREATE OBJECT o_dockingEXPORTING

    ratio = '95'.

    IF sy-subrc EQ 0.* Creating Grid

    CREATE OBJECT o_grid

    EXPORTING

    i_parent = o_docking.ENDIF.

    ENDFORM. " create_object

    *&---------------------------------------------------------------------*

    *& Form create_fieldcat*&---------------------------------------------------------------------*

    * Filling the fieldcatalog table

    *----------------------------------------------------------------------*FORM create_fieldcat .

  • 7/27/2019 Oops Alv Feild Catalog q & A

    6/9

    * Filling the fieldcatalog table

    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

    EXPORTINGi_structure_name = 'ZZZTABLE'

    CHANGING

    ct_fieldcat = i_fieldcatEXCEPTIONSinconsistent_interface = 1

    program_error = 2

    OTHERS = 3.ENDFORM. " create_fieldcat

    *&---------------------------------------------------------------------*

    *& Form modify_fieldcat

    *&---------------------------------------------------------------------** Making the column as ediable

    *----------------------------------------------------------------------*

    FORM modify_fieldcat .LOOP AT i_fieldcat ASSIGNING .

    CASE -fieldname.

    when 'FULLTIMEEMPLOYEE'.

    -checkbox = 'X'.-coltext = 'Fulltime'.

    -edit = 'X'.

    -outputlen = '8'.when 'ENO'.

    -key = ' '.

    -coltext = 'Employee Number'.

    -edit = ' '.when 'AGE'.

    -no_out = 'X'.

    -coltext = 'Age'.-edit = 'X'.

    -just = 'R'.

    when 'GENDER'.-coltext = 'Gender'.

    -outputlen = '6'.

    -tech = 'X'.

    when 'SALARY'.-emphasize = 'C411'.

    -do_sum = 'X'.

    -coltext = 'Salary'.

    -edit = 'X'.when 'ENAME'.

    -coltext = 'Employee Name'.

    -edit = 'X'.-TOOLTIP = 'Emp. Name'.

  • 7/27/2019 Oops Alv Feild Catalog q & A

    7/9

    ENDCASE.

    ENDLOOP.

    ENDFORM. " modify_fieldcat*&---------------------------------------------------------------------*

    *&---------------------------------------------------------------------*

    *& Form display_output*&---------------------------------------------------------------------** Displaying the output

    *----------------------------------------------------------------------*

    FORM display_output .w_variant-report = sy-repid.

    * Displaying the output

    CALL METHOD o_grid->set_table_for_first_display

    EXPORTINGis_variant = w_variant

    i_save = ' '

    CHANGINGit_outtab = itab

    it_fieldcatalog = i_fieldcat

    EXCEPTIONS

    invalid_parameter_combination = 1program_error = 2

    too_many_lines = 3

    OTHERS = 4.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. " display_output

    *&---------------------------------------------------------------------*

    *& Form free_objects*&---------------------------------------------------------------------*

    * Free Objects

    *----------------------------------------------------------------------*FORM free_objects .

    CALL METHOD o_grid->free

    EXCEPTIONS

    cntl_error = 1cntl_system_error = 2

    OTHERS = 3.

    IF sy-subrc 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgnoWITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

    CALL METHOD o_docking->freeEXCEPTIONS

  • 7/27/2019 Oops Alv Feild Catalog q & A

    8/9

    cntl_error = 1

    cntl_system_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. " free_objects

    Output

    Coltext makes the header of the output as described.

    Edit makes the employee no. to be non-editable whereas other fields are editable.

    No_out makes the field AGE not appearing in layout. Whereas the user can select that field from

    change layout.

    Tech makes the field Gender not appearing in layout. The user cannot even select that field from

    change layout.

    Outputlen extending the column length in output as mentioned.

    Do_sum calculates the total of salary as 188,000.00.

    Emphasize colors the Salary field.

  • 7/27/2019 Oops Alv Feild Catalog q & A

    9/9

    Checkbox makes the field Fulltime appear as Checkbox.

    Just = 'R' does the right Justification of field Age.

    Tooltip makes the Emp. Name to appear as tool tip for Employee Name.

    Key = ' ' makes the Employee no. field to appear as non-key column. Because of this, we cannot

    the see the default blue color for Key field.

    Labels