0 évaluation0% ont trouvé ce document utile (0 vote)
47 vues5 pages
The document describes a report that processes financial documents from a text file. It defines data structures to store document, item, and data table information. It uploads the text file, parses the data into internal tables, and then uses BDC programming to post each document in SAP using transaction codes. Any messages generated are then written out.
The document describes a report that processes financial documents from a text file. It defines data structures to store document, item, and data table information. It uploads the text file, parses the data into internal tables, and then uses BDC programming to post each document in SAP using transaction codes. Any messages generated are then written out.
The document describes a report that processes financial documents from a text file. It defines data structures to store document, item, and data table information. It uploads the text file, parses the data into internal tables, and then uses BDC programming to post each document in SAP using transaction codes. Any messages generated are then written out.
*& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT zrbc_exercicio_07_99 NO STANDARD PAGE HEADING. *{ Declara estrutura STRUCTURE TYPES: BEGIN OF st_doc, id(2), data(8), tp_doc(2), empresa(4), moeda(3), periodo(2), texto(40), END OF st_doc. TYPES: BEGIN OF st_item, id(2), chave_d(2), conta_d(10), valor_d(10), chave_c(2), conta_c(10), valor_c(10), END OF st_item. TYPES: BEGIN OF st_dados, texto(200), END OF st_dados. *&---------------------------------------------------------------------* *& Tabelas Internas *&---------------------------------------------------------------------* DATA: ti_doc TYPE st_doc OCCURS 0 WITH HEADER LINE, ti_item TYPE st_item OCCURS 0 WITH HEADER LINE, ti_dados TYPE st_dados OCCURS 0 WITH HEADER LINE. DATA BEGIN OF int_bdc OCCURS 100. INCLUDE STRUCTURE bdcdata. DATA END OF int_bdc. *&---------------------------------------------------------------------* *& Parametros de Selecao *&---------------------------------------------------------------------* *PARAMETERS PC_CARRI LIKE SPFLI-CARRID OBLIGATORY. PARAMETERS p_path LIKE rlgrap-filename. TOP-OF-PAGE. WRITE text-010. * Abre janela para busca de arquivo de entrada Bancos AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path. PERFORM value_req_file_in CHANGING p_path. *&---------------------------------------------------------------------* *& Form VALUE_REQ_FILE_IN *&---------------------------------------------------------------------* FORM value_req_file_in CHANGING filename TYPE c. DATA: up_file LIKE rlgrap-filename. " PC-Upload CALL FUNCTION 'WS_FILENAME_GET' EXPORTING def_filename = ' ' def_path = 'C:\' mask = ',Texto,*.txt,Todos,*.*.' mode = 'O' title = 'Seleo de Arquivos' IMPORTING filename = up_file EXCEPTIONS OTHERS. IF sy-subrc EQ 0. "Only if name has been changed, filename = up_file. "copy the new name ENDIF. ENDFORM. " VALUE_REQ_FILE_IN *&---------------------------------------------------------------------* *& START-OF-SELECTION Inicio do Processamento *&---------------------------------------------------------------------* START-OF-SELECTION. DATA lc_texto(100). DATA: lc_msg_id LIKE t100-arbgb, lc_msg_no LIKE t100-msgnr, lc_msg_var1 LIKE balm-msgv1, lc_msg_var2 LIKE balm-msgv2, lc_msg_var3 LIKE balm-msgv3, lc_msg_var4 LIKE balm-msgv4. CALL FUNCTION 'WS_UPLOAD' EXPORTING filename = p_path TABLES data_tab = ti_dados EXCEPTIONS conversion_error = 1 file_open_error = 2 file_read_error = 3 invalid_type = 4 no_batch = 5 unknown_error = 6 invalid_table_width = 7 gui_refuse_filetransfer = 8 customer_error = 9 no_authority = 10 OTHERS = 11. 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 ti_dados. IF ti_dados-texto(1) = 'C'. MOVE: ti_dados-texto+1(2) TO ti_doc-id, ti_dados-texto+3(8) TO ti_doc-data, ti_dados-texto+11(2) TO ti_doc-tp_doc, ti_dados-texto+13(4) TO ti_doc-empresa, ti_dados-texto+17(3) TO ti_doc-moeda, ti_dados-texto+20(2) TO ti_doc-periodo, ti_dados-texto+22(40) TO ti_doc-texto. APPEND ti_doc. ENDIF. IF ti_dados-texto(1) = 'I'. MOVE: ti_dados-texto+1(2) TO ti_item-id, ti_dados-texto+3(2) TO ti_item-chave_d, ti_dados-texto+5(10) TO ti_item-conta_d, ti_dados-texto+15(10) TO ti_item-valor_d, ti_dados-texto+25(2) TO ti_item-chave_c, ti_dados-texto+27(10) TO ti_item-conta_c, ti_dados-texto+37(10) TO ti_item-valor_c. APPEND ti_item. ENDIF. ENDLOOP. * break instrutor. LOOP AT ti_doc. CLEAR int_bdc. REFRESH int_bdc. PERFORM bdc_telas USING 'SAPMF05A' '0100'. PERFORM bdc_campos USING: 'BDC_CURSOR' 'BKPF-BUKRS', 'BDC_OKCODE' '=SB', 'BKPF-BLDAT' ti_doc-data, 'BKPF-BLART' ti_doc-tp_doc, 'BKPF-BUKRS' ti_doc-empresa, 'BKPF-BUDAT' ti_doc-data, 'BKPF-MONAT' ti_doc-periodo, 'BKPF-WAERS' ti_doc-moeda, 'FS006-DOCID' '*', 'BDC_SUBSCR' 'SAPMF05A 1300APPL_SU B_T', 'BDC_SUBSCR' 'SAPLSEXM 0200APPL_SU B'. PERFORM bdc_telas USING 'SAPMF05A' '0310'. PERFORM bdc_campos USING: 'BDC_CURSOR' 'BSEG-WRBTR(02)', 'bdc_okcode' '/00'. LOOP AT ti_item WHERE id = ti_doc-id. PERFORM bdc_campos USING: 'BSEG-BSCHL(01)' ti_item-chave_d, 'BSEG-BSCHL(02)' ti_item-chave_c, 'RF05A-KONTO(01)' ti_item-conta_d, 'RF05A-KONTO(02)' ti_item-conta_c, 'BSEG-WRBTR(01)' ti_item-valor_d, 'BSEG-WRBTR(02)' ti_item-valor_c. ENDLOOP. PERFORM bdc_telas USING 'SAPMF05A' '0700'. PERFORM bdc_campos USING:
'BDC_CURSOR' 'RF05A-NEWBS', 'BDC_OKCODE' '=BU'. CALL TRANSACTION 'FB01' USING int_bdc MODE 'N' . lc_msg_id = sy-msgid. lc_msg_no = sy-msgno. lc_msg_var1 = sy-msgv1. lc_msg_var2 = sy-msgv2. lc_msg_var3 = sy-msgv3. lc_msg_var4 = sy-msgv4. CALL FUNCTION 'MESSAGE_PREPARE' EXPORTING * LANGUAGE = ' ' msg_id = lc_msg_id msg_no = lc_msg_no msg_var1 = lc_msg_var1 msg_var2 = lc_msg_var2 msg_var3 = lc_msg_var3 msg_var4 = lc_msg_var4 IMPORTING msg_text = lc_texto EXCEPTIONS function_not_completed = 1 message_not_found = 2 OTHERS = 3 . WRITE / lc_texto. ENDLOOP. *---------------------------------------------------------------------* * Form BDC_TELA *---------------------------------------------------------------------* * Pega parmetros e entra cada tela na tabela interna BDC * *---------------------------------------------------------------------* FORM bdc_telas USING p_program p_screen. CLEAR int_bdc. "Limpa tabela interna int_bdc-program = p_program. int_bdc-dynpro = p_screen. int_bdc-dynbegin = 'X'. APPEND int_bdc. CLEAR int_bdc. ENDFORM. "BDC_SCREEN *---------------------------------------------------------------------* * Form BDC_CAMPOS *---------------------------------------------------------------------* * Pega parmetros e entra os campos da tela na tabela interna BDC * * table specified for a new field. * *---------------------------------------------------------------------* FORM bdc_campos USING p_name p_value. CASE p_value. WHEN ' '. "Se valor estiver em branco, no move WHEN OTHERS. "Move valor MOVE p_name TO int_bdc-fnam. MOVE p_value TO int_bdc-fval. APPEND int_bdc. ENDCASE. CLEAR int_bdc. ENDFORM. "BDC_FIELD *-