Descrição do exemplo:
Relatorio com BATCH INPUT.
Exemplo:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
TYPE-POOLS: SLIS. TYPES: BEGIN OF TY_TABELA_01, COD_CLIENTE TYPE ZTABELA_01-COD_CLIENTE, NOME TYPE ZTABELA_01-NOME, ENDERECO TYPE ZTABELA_01-ENDERECO, END OF TY_TABELA_01. DATA: WA_TABELA TYPE BDCDATA, TI_TABELA TYPE TABLE OF BDCDATA, TI_01 TYPE TABLE OF TY_TABELA_01, WA_01 TYPE TY_TABELA_01. DATA: TI_FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV, WA_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV. PARAMETERS: P_COD TYPE ZTABELA_01-COD_CLIENTE, P_NOME TYPE ZTABELA_01-NOME, P_ENDE TYPE ZTABELA_01-ENDERECO. PERFORM F_CAMPOS USING 'SAPMSVMA' '0100' 'X' '' ''. PERFORM F_CAMPOS USING '' '' '' 'BDC_CURSOR' 'VIEWNAME'. PERFORM F_CAMPOS USING '' '' '' 'BDC_OKCODE' '=UPD'. PERFORM F_CAMPOS USING '' '' '' 'VIEWNAME' 'ZTABELA_01'. PERFORM F_CAMPOS USING '' '' '' 'VIMDYNFLDS-LTD_DTA_NO' 'X'. PERFORM F_CAMPOS USING 'SAPLZRE12AL10_T005T' '0002' 'X' '' ''. PERFORM F_CAMPOS USING '' '' '' 'BDC_CURSOR' 'ZTABELA_01-NOME(01)'. PERFORM F_CAMPOS USING '' '' '' 'BDC_OKCODE' '=NEWL'. PERFORM F_CAMPOS USING 'SAPLZRE12AL10_T005T' '0002' 'X' '' ''. PERFORM F_CAMPOS USING '' '' '' 'BDC_CURSOR' 'ZTABELA_01-ENDERECO(01)'. PERFORM F_CAMPOS USING '' '' '' 'BDC_OKCODE' '/00'. PERFORM F_CAMPOS USING '' '' '' 'ZTABELA_01-COD_CLIENTE(01)' P_COD. PERFORM F_CAMPOS USING '' '' '' 'ZTABELA_01-NOME(01)' P_NOME. PERFORM F_CAMPOS USING '' '' '' 'ZTABELA_01-ENDERECO(01)' P_ENDE. PERFORM F_CAMPOS USING 'SAPLZRE12AL10_T005T' '0002' 'X' '' ''. PERFORM F_CAMPOS USING '' '' '' 'BDC_CURSOR' 'ZTABELA_01-COD_CLIENTE(02)'. PERFORM F_CAMPOS USING '' '' '' 'BDC_OKCODE' '=BACK'. PERFORM F_CAMPOS USING 'SAPLZRE12AL10_T005T' '0002' 'X' '' ''. PERFORM F_CAMPOS USING '' '' '' 'BDC_CURSOR' 'ZTABELA_01-COD_CLIENTE(02)'. PERFORM F_CAMPOS USING '' '' '' 'BDC_OKCODE' '=BACK'. PERFORM F_CAMPOS USING 'SAPLSPO1' '0100' 'X' '' ''. PERFORM F_CAMPOS USING '' '' '' 'BDC_OKCODE' '=YES'. PERFORM F_CAMPOS USING 'SAPMSVMA' '0100' 'X' '' ''. PERFORM F_CAMPOS USING '' '' '' 'BDC_OKCODE' '/EBACK'. PERFORM F_CAMPOS USING '' '' '' 'BDC_CURSOR' 'VIEWNAME'. CALL TRANSACTION 'SM30' USING TI_TABELA MODE 'N'. IF SY-SUBRC IS INITIAL. SELECT COD_CLIENTE NOME ENDERECO FROM ZTABELA_01 INTO TABLE TI_01. PERFORM F_FIELD USING 'COD_CLIENTE'. PERFORM F_FIELD USING 'NOME'. PERFORM F_FIELD USING 'ENDERECO'. PERFORM F_GRID. ENDIF. FORM F_GRID. DATA: WA_LAYOUT TYPE SLIS_LAYOUT_ALV. WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'. WA_LAYOUT-ZEBRA = 'X'. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING IS_LAYOUT = WA_LAYOUT IT_FIELDCAT = TI_FIELDCATALOG[] TABLES T_OUTTAB = TI_01 EXCEPTIONS PROGRAM_ERROR = 1 OTHERS = 2. IF SY-SUBRC <> 0. * IMPLEMENT SUITABLE ERROR HANDLING HERE ENDIF. ENDFORM. FORM F_CAMPOS USING P_PROGRAM P_DYNPRO P_DYNBEGIN P_FNAM P_FVAL. WA_TABELA-PROGRAM = P_PROGRAM. WA_TABELA-DYNPRO = P_DYNPRO. WA_TABELA-DYNBEGIN = P_DYNBEGIN. WA_TABELA-FNAM = P_FNAM. WA_TABELA-FVAL = P_FVAL. APPEND WA_TABELA TO TI_TABELA. CLEAR WA_TABELA. ENDFORM. FORM F_FIELD USING P_CAMPO. WA_FIELDCATALOG-TABNAME = 'ZTABELA_01'. WA_FIELDCATALOG-FIELDNAME = P_CAMPO. * WA_FIELDCATALOG-REF_FIELDNAME = P_CAMPO. * WA_FIELDCATALOG-REF_TABNAME = 'TI_TABELA'. WA_FIELDCATALOG-SELTEXT_M = P_CAMPO. APPEND WA_FIELDCATALOG TO TI_FIELDCATALOG. CLEAR WA_FIELDCATALOG. ENDFORM. |
0 comentários:
Postar um comentário