Estruturando BAPI e Retorno da BAPI*----------------------------------------------------------------------*FORM chama_batch_vl01n USING us_vbeln. DATA lv_remessa TYPE vbeln. REFRESH tbl_return. CLEAR bdcmsg. " Executa batch input para EM PERFORM batch_input_vl01n USING us_vbeln. " Monta mensagens retornadas LOOP AT bdcmsg. CLEAR tbl_return. tbl_return-id = bdcmsg-msgid. tbl_return-number = bdcmsg-msgnr. tbl_return-message_v1 = bdcmsg-msgv1. tbl_return-message_v2 = bdcmsg-msgv2. tbl_return-message_v3 = bdcmsg-msgv3. tbl_return-message_v4 = bdcmsg-msgv4. CALL FUNCTION 'BAPI_MESSAGE_GETDETAIL' EXPORTING id = tbl_return-id number = tbl_return-number textformat = '' message_v1 = tbl_return-message_v1 message_v2 = tbl_return-message_v2 message_v3 = tbl_return-message_v3 message_v4 = tbl_return-message_v4 IMPORTING message = tbl_return-message. MOVE bdcmsg-msgtyp TO tbl_return-type. MOVE 'SU' TO tbl_return-id. MOVE '000' TO tbl_return-number. CLEAR: tbl_return-message_v1 , tbl_return-message_v2 , tbl_return-message_v3 , tbl_return-message_v4 . TRY. tbl_return-message_v1 = tbl_return-message(50). tbl_return-message_v2 = tbl_return-message+50(50). tbl_return-message_v3 = tbl_return-message+100(50). tbl_return-message_v4 = tbl_return-message+150(10). CATCH cx_root. ENDTRY. CLEAR tbl_return-message. APPEND tbl_return. ENDLOOP. " Remessa READ TABLE bdcmsg INDEX 1. IF bdcmsg-msgtyp = 'S'. lv_remessa = bdcmsg-msgv2. ENDIF. " Mostra mensagem de sucesso CALL FUNCTION 'C14ALD_BAPIRET2_SHOW' TABLES i_bapiret2_tab = tbl_return. " Atualizando tabelas gw_pre_registro-vgbel = lv_remessa. MODIFY zsdt016 FROM gw_pre_registro. " Atualizar tabela nf devolucoes " Atualizar tabela interna READ TABLE gt_pre_registro TRANSPORTING NO FIELDS WITH KEY mandt = gw_pre_registro-mandt nfenum = gw_pre_registro-nfenum serie = gw_pre_registro-serie cgc = gw_pre_registro-cgc kunnr = gw_pre_registro-kunnr branch = gw_pre_registro-branch tipo = gw_pre_registro-tipo. IF sy-subrc EQ 0. MODIFY gt_pre_registro FROM gw_pre_registro INDEX sy-tabix. ENDIF. " Aualizando tela CALL METHOD cl_gui_cfw=>flush.ENDFORM.*&---------------------------------------------------------------------** BATCH input para Entrada de Mercadoria*----------------------------------------------------------------------*FORM batch_input_vl01n USING p_vbeln TYPE vbak-vbeln. DATA: lv_data TYPE c LENGTH 10, lv_vstel TYPE vstel. SELECT SINGLE vstel FROM vbap INTO lv_vstel WHERE vbeln = p_vbeln. CHECK sy-subrc EQ 0. REFRESH: bdcdata. WRITE sy-datum TO lv_data. PERFORM bdc_dynpro USING 'SAPMV50A' '4001'. PERFORM bdc_field USING: 'BDC_CURSOR' 'LV50C-VBELN' , 'BDC_OKCODE' '/00' , 'LIKP-VSTEL' lv_vstel , 'LV50C-DATBI' lv_data , 'LV50C-VBELN' p_vbeln . PERFORM bdc_dynpro USING 'SAPMV50A' '1000'. PERFORM bdc_field USING: 'BDC_OKCODE' '=WABU_T' , 'BDC_SUBSCR' 'SAPMV50A 1502SUBSCREEN_HEADER' , 'BDC_SUBSCR' 'SAPMV50A 1102SUBSCREEN_BODY' , 'BDC_SUBSCR' 'SAPMV50A 0611SUBSCREEN_BOTTOM' , 'BDC_SUBSCR' 'SAPMV50A 1708SUBSCREEN_ICONBAR'. REFRESH bdcmsg. CALL TRANSACTION 'VL01N' USING bdcdata MODE 'P' MESSAGES INTO bdcmsg. COMMIT WORK AND WAIT.ENDFORM. " BATCH_INPUT_VL01N************************************************************************* ROTINA - 'BDC_DYNPRO' *************************************************************************FORM bdc_dynpro USING program dynpro. CLEAR bdcdata. bdcdata-program = program. bdcdata-dynpro = dynpro. bdcdata-dynbegin = 'X'. APPEND bdcdata.ENDFORM. "BDC_DYNPRO************************************************************************* ROTINA - 'BDC_FIELD' *************************************************************************FORM bdc_field USING fnam fval. CLEAR bdcdata. bdcdata-fnam = fnam. bdcdata-fval = fval. APPEND bdcdata.ENDFORM. "BDC_FIELD************************************************************************* ROTINA - 'BDC_TRANSACTION' *************************************************************************