SAP ABAP REPORT
From SapWiki
Revision as of 15:48, 21 March 2022 by WikiSysop (talk | contribs) (→EXPORTING LIST TO MEMORY AND RETURN)
Contents
- 1 Obtener vía F4 archivo y directorio en un reporte
- 2 F4 en reporte
- 3 Forzar enter
- 4 Selection Screens
- 4.1 Agregar botones en la pantalla de selección de un Reporte
- 4.2 Default Values for Selection Criteria
- 4.3 Selection Screens, Changing the Default GUI Status
- 4.4 Selection Screens, Display Properties for Parameters
- 4.5 Datos de selección (select-options, parameters) en dynpro
- 4.6 Restricciones en select-options
- 5 SUBMIT
- 6 DYNPRO
Obtener vía F4 archivo y directorio en un reporte
F4 en reporte
Forzar enter
CALL FUNCTION 'SAPGUI_SET_FUNCTIONCODE' EXPORTING functioncode = '/00' EXCEPTIONS function_not_supported = 1 OTHERS = 2.
Selection Screens
Agregar botones en la pantalla de selección de un Reporte
Default Values for Selection Criteria
REPORT demo_sel_screen_select_default. DATA wa_spfli TYPE spfli. SELECT-OPTIONS airline FOR wa_spfli-carrid DEFAULT 'AA' TO 'LH' OPTION nb "not between SIGN i. "I
Selection Screens, Changing the Default GUI Status
REPORT demo_sel_screen_status . DATA itab TYPE TABLE OF sy-ucomm. PARAMETERS test(10) TYPE c. AT SELECTION-SCREEN OUTPUT. itab = VALUE #( ( CONV sy-ucomm( 'PRIN' ) ) ( CONV sy-ucomm( 'SPOS' ) ) ). CALL FUNCTION 'RS_SET_SELSCREEN_STATUS' EXPORTING p_status = sy-pfkey TABLES p_exclude = itab.
Selection Screens, Display Properties for Parameters
PARAMETERS: p_rep AS CHECKBOX. SELECTION-SCREEN BEGIN OF BLOCK part6 WITH FRAME TITLE TEXT-006. PARAMETERS: test1(10) TYPE c MODIF ID sc1, test2(10) TYPE c MODIF ID sc1, test3(10) TYPE c MODIF ID sc1, test4(10) TYPE c MODIF ID sc1. SELECTION-SCREEN END OF BLOCK part6. AT SELECTION-SCREEN OUTPUT. LOOP AT SCREEN INTO DATA(screen_wa). IF p_rep <> 'X' AND screen_wa-group1 = 'SC1'. screen_wa-active = '0'. MODIFY SCREEN FROM screen_wa. ENDIF. IF p_rep = 'X' AND screen_wa-group1 = 'SC1'. screen_wa-active = '1'. MODIFY SCREEN FROM screen_wa. ENDIF. ENDLOOP.
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_program 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
EXPORTING LIST TO MEMORY AND RETURN
FUNCTION z_fi_rfitemar. *"---------------------------------------------------------------------- *"*"Interfase local *" IMPORTING *" VALUE(I_KUNNR) TYPE KNA1-KUNNR *" EXPORTING *" VALUE(E_TOTAL) TYPE /PRA/TOTAL_AMT_OWED *"---------------------------------------------------------------------- DATA: it_kunnr_sel TYPE fiappt_t_kunnr, ls_kunnr_sel TYPE LINE OF fiappt_t_kunnr. DATA: lt_bukrs_range TYPE RANGE OF bukrs, ls_bukrs_range LIKE LINE OF lt_bukrs_range. DATA l_total TYPE /pra/total_amt_owed. data l_sign type i VALUE 1. ls_kunnr_sel-low = i_kunnr. ls_kunnr_sel-sign = 'I'. ls_kunnr_sel-option = 'EQ'. APPEND ls_kunnr_sel TO it_kunnr_sel. SUBMIT rfitemar WITH dd_kunnr IN it_kunnr_sel[] WITH dd_bukrs IN lt_bukrs_range[] WITH x_aisel EQ 'X' * WITH pa_stida EQ ls_fiapptd_balance-reference_date WITH x_norm EQ 'X' WITH x_shbv EQ 'X' WITH pa_vari EQ '/COTE' EXPORTING LIST TO MEMORY AND RETURN. * Tipo TYPES : BEGIN OF ltyp_lista_asci, texto(500) TYPE c, END OF ltyp_lista_asci. DATA lt_lista_mem TYPE TABLE OF abaplist. DATA lt_lista_asci TYPE TABLE OF ltyp_lista_asci. DATA ls_lista_asci TYPE ltyp_lista_asci. CALL FUNCTION 'LIST_FROM_MEMORY' TABLES listobject = lt_lista_mem EXCEPTIONS not_found = 1 OTHERS = 2. CALL FUNCTION 'LIST_TO_ASCI' EXPORTING with_line_break = 'X' TABLES listasci = lt_lista_asci listobject = lt_lista_mem EXCEPTIONS empty_list = 1 list_index_invalid = 2 OTHERS = 3. DATA(l_lines) = lines( lt_lista_asci ). IF l_lines > 2. l_lines = l_lines - 1. ls_lista_asci = lt_lista_asci[ l_lines ]. IF ls_lista_asci CS '**'. "leer total importe en moneda local *"leer total importe en moneda local, ejemplo línea: *| ** | | | | | | |1107538|CLP | | | | * verificar si es negativo if ls_lista_asci ca '-'. l_sign = l_sign * -1. endif. REPLACE ALL OCCURRENCES OF REGEX '[^\d]' IN ls_lista_asci WITH ''. CONDENSE ls_lista_asci. MOVE ls_lista_asci TO e_total. e_total = e_total * l_sign. ENDIF. ENDIF. ENDFUNCTION.
DYNPRO
Ver programas demos DEMO_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