Difference between revisions of "SAP ABAP REPORT"
From SapWiki
(→DYNPRO) |
|||
Line 85: | Line 85: | ||
restriction = restrict.</nowiki> | restriction = restrict.</nowiki> | ||
+ | ==SUBMIT== | ||
+ | <nowiki>FORM submit_prestamos USING p_index. | ||
+ | DATA: rspar_tab TYPE TABLE OF rsparams, | ||
+ | rspar_line LIKE LINE OF rspar_tab. | ||
+ | |||
+ | READ TABLE gt_data INTO wa_data INDEX p_index. | ||
+ | IF sy-subrc = 0. | ||
+ | rspar_line-selname = 'PNPPERNR'. | ||
+ | rspar_line-kind = 'S'. | ||
+ | rspar_line-sign = 'I'. | ||
+ | rspar_line-option = 'EQ'. | ||
+ | rspar_line-low = wa_data-pernr. | ||
+ | APPEND rspar_line TO rspar_tab. | ||
+ | ENDIF. | ||
+ | |||
+ | rspar_line-selname = 'PNPBEGDA'. | ||
+ | rspar_line-kind = 'S'. | ||
+ | rspar_line-sign = 'I'. | ||
+ | rspar_line-option = 'EQ'. | ||
+ | rspar_line-low = '18000101'. | ||
+ | APPEND rspar_line TO rspar_tab. | ||
+ | |||
+ | rspar_line-selname = 'PNPENDDA'. | ||
+ | rspar_line-kind = 'S'. | ||
+ | rspar_line-sign = 'I'. | ||
+ | rspar_line-option = 'EQ'. | ||
+ | rspar_line-low = sy-datum. | ||
+ | APPEND rspar_line TO rspar_tab. | ||
+ | |||
+ | SUBMIT zhcmrp_programa_det "VIA SELECTION-SCREEN | ||
+ | WITH SELECTION-TABLE rspar_tab | ||
+ | WITH p_de EQ 'X' "rep. detallado | ||
+ | AND RETURN. | ||
+ | |||
+ | ENDFORM. "submit_prestamos</nowiki> | ||
+ | |||
+ | Ver demo DEMO_PROGRAM_SUBMIT_SEL_SCREEN | ||
==DYNPRO== | ==DYNPRO== | ||
===Crear texto y Icono dinamico para pushbutton=== | ===Crear texto y Icono dinamico para pushbutton=== |
Revision as of 19:02, 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.
SUBMIT
FORM submit_prestamos USING p_index. DATA: rspar_tab TYPE TABLE OF rsparams, rspar_line LIKE LINE OF rspar_tab. READ TABLE gt_data INTO wa_data INDEX p_index. IF sy-subrc = 0. rspar_line-selname = 'PNPPERNR'. rspar_line-kind = 'S'. rspar_line-sign = 'I'. rspar_line-option = 'EQ'. rspar_line-low = wa_data-pernr. APPEND rspar_line TO rspar_tab. ENDIF. rspar_line-selname = 'PNPBEGDA'. rspar_line-kind = 'S'. rspar_line-sign = 'I'. rspar_line-option = 'EQ'. rspar_line-low = '18000101'. APPEND rspar_line TO rspar_tab. rspar_line-selname = 'PNPENDDA'. rspar_line-kind = 'S'. rspar_line-sign = 'I'. rspar_line-option = 'EQ'. rspar_line-low = sy-datum. APPEND rspar_line TO rspar_tab. SUBMIT zhcmrp_programa_det "VIA SELECTION-SCREEN WITH SELECTION-TABLE rspar_tab WITH p_de EQ 'X' "rep. detallado AND RETURN. ENDFORM. "submit_prestamos
Ver demo DEMO_PROGRAM_SUBMIT_SEL_SCREEN
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