Contoh/Example Syntax ALV Grid / List (ALVProgramming)27/07/2010 — eryantaUntukkeperluan reporting, SAP menyediakan Functi...
PERFORM f_build_layout.PERFORM f_build_events.PERFORM f_build_print_params.PERFORM f_display_alv_report.*&————————————————...
*&———————————————————————*FORM f_build_fieldcatalog .PERFORM f_sub_fill_alv_field_catalog USING:’01′ ’01′ ’ICON’ ’T_EKPO’ ...
i_list_type = 0IMPORTINGet_events    = t_events[]EXCEPTIONSlist_type_wrong = 1OTHERS         = 2.IF sy-subrc <> 0.* MESSAG...
* I_BYPASSING_BUFFER                   =’’* I_BUFFER_ACTIVE                   =’’i_callback_program            = d_repidi_...
IF sy-subrc <> 0.* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO*      WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.ENDIF....
*&———————————————————————**& Form F_TOP_OF_PAGE*&———————————————————————*FORM f_top_of_page.*ALV Header DeclarationsDATA: ...
*&———————————————————————**& Form F_ALV_STATUS*&———————————————————————*FORM f_alv_status USING fu_extab TYPE slis_t_extab...
Kemudianbuat GUI Status dengan status “STANDARD”.Kemudianpilih Template Status “List Viewer” (Extras>Adjust Template).Acti...
CMIIW
Upcoming SlideShare
Loading in …5
×

Example syntax alv grid list

2,267 views

Published on

SAP

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,267
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
73
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Example syntax alv grid list

  1. 1. Contoh/Example Syntax ALV Grid / List (ALVProgramming)27/07/2010 — eryantaUntukkeperluan reporting, SAP menyediakan Function Module ALV (ABAP ListViewer/Apllication List Viewer).Berikutinicontoh syntax untukmembuat ALV Grid atau List.Syntax di Include TOPtype-POOLs: slis, icon.TYPES : BEGIN OF ty_ekpo,cell,icon(5),ebeln TYPE ekpo-ebeln,ebeln1 TYPE ekpo-ebeln,ebelp TYPE ekpo-ebelp,statu TYPE ekpo-statu,aedat TYPE ekpo-aedat,matnr TYPE ekpo-matnr,menge TYPE ekpo-menge,meins TYPE ekpo-meins,netpr TYPE ekpo-netpr,peinh TYPE ekpo-peinh,line_color(4),END OF ty_ekpo.data: t_ekpo TYPE TABLE OF ty_ekpo,x_ekpo TYPE ty_ekpo.*ALV Data declarationdata: t_fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,d_tab_group TYPE slis_t_sp_group_alv,x_layout TYPE slis_layout_alv,d_repid like sy-repid,t_events TYPE slis_t_event,x_prntparams TYPE slis_print_alv,t_sort TYPE slis_t_sortinfo_alv,t_alv_isort TYPE slis_t_sortinfo_alv WITH HEADER LINE,t_alv_extab TYPE slis_t_extab WITH HEADER LINE.Syntax di Include F01PERFORM f_get_data.PERFORM f_build_fieldcatalog.
  2. 2. PERFORM f_build_layout.PERFORM f_build_events.PERFORM f_build_print_params.PERFORM f_display_alv_report.*&———————————————————————**& Form F_GET_DATA*&———————————————————————*FORM f_get_data .DATA ld_color.SELECT ebeln ebelp statu aedat matnr menge meins netpr peinhUP TO 10 ROWS FROM ekpoINTO CORRESPONDING FIELDS OF TABLE t_ekpo.*Populate field with color attributesLOOP AT t_ekpo INTO x_ekpo.x_ekpo-ebeln1 = x_ekpo-ebeln.* Populate color variable with colour properties* Char 1 = C (This is a color property)* Char 2 = 3 (Color codes: 1 - 7)* Char 3 = Intensified on/off ( 1 or 0 )* Char 4 = Inverse display on/off ( 1 or 0 )* i.e. wa_ekpo-line_color = ’C410′ld_color = ld_color + 1.* Only 7 colours so need to reset color valueIF ld_color = 8.ld_color = 1.ENDIF.CONCATENATE ’C ld_color ’10′ INTO x_ekpo-line_color.* Show IconIF ld_color = 1.x_ekpo-icon = ’@08@’.ELSEif ld_color = 2.x_ekpo-icon = ’@09@’.else.x_ekpo-icon = ’@0A@’.ENDIF.* wa_ekpo-line_color = ’C410′.MODIFY t_ekpo FROM x_ekpo.ENDLOOP.ENDFORM.“ F_GET_DATA*&———————————————————————**& Form F_BUILD_FIELDCATALOG
  3. 3. *&———————————————————————*FORM f_build_fieldcatalog .PERFORM f_sub_fill_alv_field_catalog USING:’01′ ’01′ ’ICON’ ’T_EKPO’ ’R ’Light Status’ ” ” ” ”,’01′ ’02′ ’EBELN1′ ’T_EKPO’ ’L ’Purchase Order’ ” ” ” ”,’01′ ’02′ ’EBELN’ ’T_EKPO’ ’L ’Purchase Order’ ’X ’X ” ”,’01′ ’03′ ’EBELP’ ’T_EKPO’ ’L ’PO Item’ ” ” ” ”,’01′ ’04′ ’STATU’ ’T_EKPO’ ’L ’Statu’ ” ” ” ”,’01′ ’05′ ’AEDAT’ ’T_EKPO’ ’L ’Item change date’ ” ” ” ”,’01′ ’06′ ’MATNR’ ’T_EKPO’ ’L ’Material Number’ ” ” ” ”,’01′ ’07′ ’MENGE’ ’T_EKPO’ ’L ’PO Quantity’ ” ” ” ”,’01′ ’08′ ’MEINS’ ’T_EKPO’ ’L ’Order Unit’ ” ” ” ”,’01′ ’09′ ’NETPR’ ’T_EKPO’ ’R ’Net Price’ ” ” ” ”,’01′ ’10′ ’PEINH’ ’T_EKPO’ ’L ’Price Unit’ ” ” ” ”.* DATA SORTING AND SUBTOTALDATA: lx_sort TYPE slis_sortinfo_alv.CLEAR lx_sort.lx_sort-fieldname = ’EBELN’.lx_sort-spos = 1.lx_sort-up = ’X’.lx_sort-subtot = ’X’.APPEND lx_sort to t_sort.ENDFORM.“ F_BUILD_FIELDCATALOG*&———————————————————————**& Form F_BUILD_LAYOUT*&———————————————————————*FORM f_build_layout .x_layout-colwidth_optimize = ’X’.x_layout-box_tabname = ’T_EKPO’.x_layout-zebra = ’X’.*x_layout-edit = ’X’.x_layout-info_fieldname = ’LINE_COLOR’.x_layout-box_fieldname = ’CELL’.ENDFORM.“ F_BUILD_LAYOUT*&———————————————————————**& Form F_BUILD_EVENTS*&———————————————————————*FORM f_build_events .DATA: lx_events TYPE slis_alv_event.CONSTANTS: c_formname_subtotal_text TYPE slis_formnameVALUE ’F_SUBTOTAL_TEXT’.CALL FUNCTION ’REUSE_ALV_EVENTS_GET’EXPORTING
  4. 4. i_list_type = 0IMPORTINGet_events = t_events[]EXCEPTIONSlist_type_wrong = 1OTHERS = 2.IF sy-subrc <> 0.* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.ENDIF.LOOP AT t_events INTO lx_events.CASE lx_events-name.WHEN slis_ev_top_of_page.MOVE ’F_TOP_OF_PAGE’ TO lx_events-form.ENDCASE.MODIFY t_events FROM lx_events.ENDLOOP.*SubtotalCLEAR lx_events.READ TABLE t_events INTO lx_eventsWITH KEY name = slis_ev_subtotal_text.if sy-subrc eq 0.MOVE c_formname_subtotal_text to lx_events-form.MODIFY t_events FROM lx_events INDEX sy-tabix.ENDIF.ENDFORM.“ F_BUILD_EVENTS*&———————————————————————**& Form F_BUILD_PRINT_PARAMS*&———————————————————————*FORM f_build_print_params .ENDFORM.“ F_BUILD_PRINT_PARAMS*&———————————————————————**& Form F_DISPLAY_ALV_REPORT*&———————————————————————*FORM f_display_alv_report .d_repid = sy-repid.CALL FUNCTION ’REUSE_ALV_GRID_DISPLAY’EXPORTING* I_INTERFACE_CHECK =’’
  5. 5. * I_BYPASSING_BUFFER =’’* I_BUFFER_ACTIVE =’’i_callback_program = d_repidi_callback_pf_status_set = ’F_ALV_STATUS’i_callback_user_command = ’F_USER_COMMAND’* I_CALLBACK_TOP_OF_PAGE =’’* I_CALLBACK_HTML_TOP_OF_PAGE =’’* I_CALLBACK_HTML_END_OF_LIST =’’* I_STRUCTURE_NAME =* I_BACKGROUND_ID =’’* I_GRID_TITLE =* I_GRID_SETTINGS =is_layout = x_layoutit_fieldcat = t_fieldcatalog[]* IT_EXCLUDING =* IT_SPECIAL_GROUPS =IT_SORT = t_sort* IT_FILTER =* IS_SEL_HIDE =i_default = ’X’i_save = ’A’* IS_VARIANT =it_events = t_events* IT_EVENT_EXIT =is_print = x_prntparams* IS_REPREP_ID =* I_SCREEN_START_COLUMN =0* I_SCREEN_START_LINE =0* I_SCREEN_END_COLUMN =0* I_SCREEN_END_LINE =0* I_HTML_HEIGHT_TOP =0* I_HTML_HEIGHT_END =0* IT_ALV_GRAPHICS =* IT_HYPERLINK =* IT_ADD_FIELDCAT =* IT_EXCEPT_QINFO =* IR_SALV_FULLSCREEN_ADAPTER =* IMPORTING* E_EXIT_CAUSED_BY_CALLER =* ES_EXIT_CAUSED_BY_USER =TABLESt_outtab = t_ekpoEXCEPTIONSPROGRAM_ERROR =1OTHERS =2.
  6. 6. 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. ” F_DISPLAY_ALV_REPORT*&———————————————————————**& Form F_SUB_FILL_ALV_FIELD_CATALOG*&———————————————————————*FORM f_sub_fill_alv_field_catalog USINGp_rowpos TYPE sycurowp_colpos TYPE sycucolp_fldnam TYPE fieldnamep_tabnam TYPE tabnamep_justif TYPE char1p_seltext TYPE dd03p-scrtext_lp_out TYPE char1p_tech TYPE char1p_qfield TYPE slis_fieldnamep_qtab TYPE slis_tabname.DATA: lx_fcat TYPE slis_fieldcat_alv.lx_fcat-row_pos = p_rowpos.lx_fcat-col_pos = p_colpos.lx_fcat-fieldname = p_fldnam.lx_fcat-tabname = p_tabnam.lx_fcat-just = p_justif.lx_fcat-seltext_l = p_seltext.lx_fcat-no_out = p_out.lx_fcat-tech = p_tech.lx_fcat-qfieldname = p_qfield.lx_fcat-qtabname = p_qtab.IF p_fldnam = ’NETPR’.lx_fcat-do_sum = ’X’.ENDIF.APPEND lx_fcat TO t_fieldcatalog.CLEAR lx_fcat.ENDFORM.“ F_SUB_FILL_ALV_FIELD_CATALOG
  7. 7. *&———————————————————————**& Form F_TOP_OF_PAGE*&———————————————————————*FORM f_top_of_page.*ALV Header DeclarationsDATA: lt_header TYPE slis_t_listheader,lx_header TYPE slis_listheader,lt_line LIKE lx_header-info,ld_lines TYPE i,ld_linesc(10) TYPE c.*Titlelx_header-typ = ’H’.lx_header-info = ’EKPO Table Report’.APPEND lx_header TO lt_header.CLEAR lx_header.*Datelx_header-typ = ’S’.lx_header-key = ’Date: ’.CONCATENATE sy-datum+6(2) ’.’sy-datum+4(2) ’.’sy-datum(4) INTO lx_header-info.APPEND lx_header TO lt_header.CLEAR lx_header.*Total No. of records SelectedDESCRIBE TABLE t_ekpo LINES ld_lines.ld_linesc = ld_lines.CONCATENATE ’Total No. of records Selected: ’ ld_linescINTO lt_line SEPARATED BY space.lx_header-typ = ’A’.lx_header-info = lt_line.APPEND lx_header TO lt_header.CLEAR: lx_header, lt_line.CALL FUNCTION ’REUSE_ALV_COMMENTARY_WRITE’EXPORTINGit_list_commentary = lt_header* I_LOGO = ’PHOTOTRI’* I_END_OF_LIST_GRID =* I_ALV_FORM =.ENDFORM. “F_TOP_OF_PAGE
  8. 8. *&———————————————————————**& Form F_ALV_STATUS*&———————————————————————*FORM f_alv_status USING fu_extab TYPE slis_t_extab.REFRESH fu_extab.SET PF-STATUS ’STANDARD’ EXCLUDING fu_extab.ENDFORM. “F_ALV_STATUS*&———————————————————————**& Form F_USER_COMMAND*&———————————————————————*FORM f_user_command USING ld_r_ucomm LIKE sy-ucommlx_rs_selfield TYPE slis_selfield.CASE ld_r_ucomm.WHEN ’&IC1′.IF lx_rs_selfield-fieldname = ’EBELN1′.READ TABLE t_ekpo INTO x_ekpo INDEX lx_rs_selfield-tabindex.MESSAGE i003(aq) WITH ’Anda memilih Purchase order ’x_ekpo-ebeln.CLEAR x_ekpo.ENDIF.WHEN ’SHOW’.LOOP AT t_ekpo INTO x_ekpo.IF x_ekpo-cell EQ ’X’.MESSAGE i003(aq) WITH ’Anda memilih Purchase order ’x_ekpo-ebeln1.ENDIF.ENDLOOP.CLEAR x_ekpo.ENDCASE.ENDFORM. “F_USER_COMMANDFORM F_SUBTOTAL_TEXT CHANGING ld_total TYPE anyld_subtot_text TYPE slis_subtot_text.*Material level sub totalif ld_subtot_text-criteria = ’EBELN’.ld_subtot_text-display_text_for_subtotal= ’Subtotal’.ENDIF.ENDFORM.
  9. 9. Kemudianbuat GUI Status dengan status “STANDARD”.Kemudianpilih Template Status “List Viewer” (Extras>Adjust Template).Activate semua, lalueksekusi.Hasilnyaadalah “ALV Grid”, untukmengubahmenjadi“ALV List”, masukke subroutine“FORM f_display_alv_report“, ubah ” ”CALL FUNCTION ’REUSE_ALV_GRID_DISPLAYmenjadi ”CALL FUNCTION ’REUSE_ALV_LIST_DISPLAY “.
  10. 10. CMIIW

×