Difference between revisions of "SAP ABAP REPORT"
From SapWiki
Line 111: | Line 111: | ||
ejemplo: ver programa DEMO_DYNPRO_STATUS_ICONS | ejemplo: ver programa DEMO_DYNPRO_STATUS_ICONS | ||
+ | |||
+ | ===F4 en Dynpro=== | ||
+ | Custom matchcode y Obtener valor de campo en pantalla | ||
+ | |||
+ | <nowiki>DATA: progname TYPE sy-repid, | ||
+ | dynnum TYPE sy-dynnr. | ||
+ | data: BEGIN OF gs_werks, | ||
+ | werks like t001w-werks, | ||
+ | name1 like t001w-name1, | ||
+ | END OF gs_werks. | ||
+ | data gt_werks like TABLE OF gs_werks. | ||
+ | |||
+ | PROCESS AFTER INPUT. | ||
+ | MODULE FUNcTION_exit AT EXIT-COMMAND. | ||
+ | field likp-vbeln module select_entrega. | ||
+ | field lips-werks module select_centro. | ||
+ | field zsd_plan_tra-tplst module select_centro_despacho. | ||
+ | MODULE USER_COMMAND_0010. | ||
+ | |||
+ | PROCESS ON VALUE-REQUEST. | ||
+ | field lips-werks module value_werks_by_bukrs. | ||
+ | |||
+ | MODULE VALUE_werks_BY_bukrs INPUT. | ||
+ | data L_FIELDS type table of DYNPREAD with header line. | ||
+ | data ld_vbeln(10) type n. | ||
+ | |||
+ | progname = sy-repid. | ||
+ | dynnum = sy-dynnr. | ||
+ | |||
+ | L_FIELDS-FIELDNAME = 'LIKP-VBELN'. | ||
+ | append L_FIELDS. | ||
+ | |||
+ | call function 'DYNP_VALUES_READ' | ||
+ | exporting | ||
+ | DYNAME = progname | ||
+ | DYNUMB = dynnum | ||
+ | tables | ||
+ | DYNPFIELDS = L_FIELDS. | ||
+ | |||
+ | loop at L_FIELDS. | ||
+ | case L_FIELDS-FIELDNAME. | ||
+ | when 'LIKP-VBELN'. | ||
+ | ld_vbeln = L_FIELDS-FIELDVALUE. | ||
+ | endcase. | ||
+ | endloop. | ||
+ | |||
+ | SELECT SINGLE werks | ||
+ | INTO gd_werks | ||
+ | FROM lips | ||
+ | WHERE vbeln = ld_vbeln. | ||
+ | |||
+ | SELECT single * | ||
+ | FROM t001k | ||
+ | WHERE bwkey = gd_werks. | ||
+ | |||
+ | PERFORM GET_werks_by_bukrs using t001k-bukrs. | ||
+ | |||
+ | CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' | ||
+ | EXPORTING | ||
+ | retfield = 'WERKS' | ||
+ | dynpprog = progname | ||
+ | dynpnr = dynnum | ||
+ | dynprofield = 'LIPS_WERKS' | ||
+ | value_org = 'S' | ||
+ | TABLES | ||
+ | value_tab = gt_werks. | ||
+ | ENDMODULE. " VALUE_BUKRS_BY_ORG INPUT | ||
+ | |||
+ | FORM GET_werks_BY_bukrs USING i_bukrs. | ||
+ | clear gt_werks[]. | ||
+ | |||
+ | select j~werks | ||
+ | j~name1 | ||
+ | into CORRESPONDING FIELDS OF TABLE gt_werks | ||
+ | from t001k as i inner join t001w as j | ||
+ | on i~bwkey = j~werks | ||
+ | where i~bukrs = i_bukrs. | ||
+ | if gt_werks[] is INITIAL. | ||
+ | select j~werks | ||
+ | j~name1 | ||
+ | into CORRESPONDING FIELDS OF TABLE gt_werks | ||
+ | from t001k as i inner join t001w as j | ||
+ | on i~bwkey = j~werks. | ||
+ | endif. | ||
+ | sort gt_werks by werks. | ||
+ | ENDFORM. " GET_BUKRS_BY_ORG</nowiki> |
Revision as of 18:28, 12 April 2020
Contents
Obtener vía F4 archivo y directorio en un reporte
F4 en reporte
Agregar botones en la pantalla de selección de un Reporte
Datos de selección (select-options, parameters) en dynpro
REPORT ydemo_sel. DATA wa_pa0002 TYPE pa0002. SELECTION-SCREEN BEGIN OF SCREEN 100. PARAMETERS p_pernr TYPE p0001-pernr. SELECT-OPTIONS s_vorna FOR wa_pa0002-vorna. SELECTION-SCREEN END OF SCREEN 100. AT SELECTION-SCREEN OUTPUT. SET PARAMETER ID 'RID' FIELD 'TEST_PROGRAM'. CLASS start DEFINITION. PUBLIC SECTION. CLASS-METHODS main. ENDCLASS. CLASS start IMPLEMENTATION. METHOD main. CALL SELECTION-SCREEN 100. " STARTING AT 10 10. IF sy-subrc <> 0. RETURN. ENDIF. SELECT pernr INTO TABLE @DATA(lt_pernr) FROM pa0001 UP TO 100 ROWS WHERE pernr = @p_pernr . SELECT * INTO TABLE @DATA(lt_pernr2) FROM pa0002 UP TO 100 ROWS WHERE vorna IN @s_vorna . TRY. cl_salv_table=>factory( IMPORTING r_salv_table = DATA(gr_table) CHANGING t_table = lt_pernr2 ). CATCH cx_salv_msg. ENDTRY. *... Enable Generic ALV functions DATA(gr_functions) = gr_table->get_functions( ). gr_functions->set_all( ). *... Display table gr_table->display( ). ENDMETHOD. ENDCLASS. START-OF-SELECTION. start=>main( ).
Restricciones en select-options
Ejemplo de select-options que solo permite valores individuales
REPORT ydemo_sel2. DATA p0014 TYPE p0014. SELECT-OPTIONS s_lgart FOR p0014-lgart NO INTERVALS. *--------------------------------------------------------------------* INITIALIZATION. *--------------------------------------------------------------------* DATA: restrict TYPE sscr_restrict, opt_list TYPE sscr_opt_list_tab WITH HEADER LINE, sscr_ass TYPE sscr_ass_tab WITH HEADER LINE. * restrict selection option for function to single value CLEAR opt_list. MOVE 'EQ' TO opt_list-name. MOVE 'X' TO opt_list-options-eq. APPEND opt_list TO restrict-opt_list_tab. CLEAR sscr_ass. MOVE: 'S' TO sscr_ass-kind, 'S_LGART' TO sscr_ass-name, 'I' TO sscr_ass-sg_main, ' ' TO sscr_ass-sg_addy, 'EQ' TO sscr_ass-op_main, 'EQ' TO sscr_ass-op_addy. APPEND sscr_ass TO restrict-ass_tab. CALL FUNCTION 'SELECT_OPTIONS_RESTRICT' EXPORTING restriction = restrict.
DYNPRO
Crear texto y Icono dinamico para pushbutton
crear variable en declaracion
data pb_sa(128).
crear pushbutton en dynpro llamado PB_SA y marcar "Campo de salida" y "Con Icono"
en PBO de dynpro
CALL FUNCTION 'ICON_CREATE' EXPORTING NAME = ICON_SYSTEM_SAVE TEXT = 'F5 Save' * INFO = ' ' * ADD_STDINF = 'X' IMPORTING RESULT = pb_sa EXCEPTIONS ICON_NOT_FOUND = 1 OUTPUTFIELD_TOO_SHORT = 2 OTHERS = 3 . IF SY-SUBRC <> 0. ENDIF.
ejemplo: ver programa DEMO_DYNPRO_STATUS_ICONS
F4 en Dynpro
Custom matchcode y Obtener valor de campo en pantalla
DATA: progname TYPE sy-repid, dynnum TYPE sy-dynnr. data: BEGIN OF gs_werks, werks like t001w-werks, name1 like t001w-name1, END OF gs_werks. data gt_werks like TABLE OF gs_werks. PROCESS AFTER INPUT. MODULE FUNcTION_exit AT EXIT-COMMAND. field likp-vbeln module select_entrega. field lips-werks module select_centro. field zsd_plan_tra-tplst module select_centro_despacho. MODULE USER_COMMAND_0010. PROCESS ON VALUE-REQUEST. field lips-werks module value_werks_by_bukrs. MODULE VALUE_werks_BY_bukrs INPUT. data L_FIELDS type table of DYNPREAD with header line. data ld_vbeln(10) type n. progname = sy-repid. dynnum = sy-dynnr. L_FIELDS-FIELDNAME = 'LIKP-VBELN'. append L_FIELDS. call function 'DYNP_VALUES_READ' exporting DYNAME = progname DYNUMB = dynnum tables DYNPFIELDS = L_FIELDS. loop at L_FIELDS. case L_FIELDS-FIELDNAME. when 'LIKP-VBELN'. ld_vbeln = L_FIELDS-FIELDVALUE. endcase. endloop. SELECT SINGLE werks INTO gd_werks FROM lips WHERE vbeln = ld_vbeln. SELECT single * FROM t001k WHERE bwkey = gd_werks. PERFORM GET_werks_by_bukrs using t001k-bukrs. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING retfield = 'WERKS' dynpprog = progname dynpnr = dynnum dynprofield = 'LIPS_WERKS' value_org = 'S' TABLES value_tab = gt_werks. ENDMODULE. " VALUE_BUKRS_BY_ORG INPUT FORM GET_werks_BY_bukrs USING i_bukrs. clear gt_werks[]. select j~werks j~name1 into CORRESPONDING FIELDS OF TABLE gt_werks from t001k as i inner join t001w as j on i~bwkey = j~werks where i~bukrs = i_bukrs. if gt_werks[] is INITIAL. select j~werks j~name1 into CORRESPONDING FIELDS OF TABLE gt_werks from t001k as i inner join t001w as j on i~bwkey = j~werks. endif. sort gt_werks by werks. ENDFORM. " GET_BUKRS_BY_ORG