= tbl_bapicond sales_conditions_inx = tbl_bapicondx conditions_ex = tbl_bapicond_ex.* CALL FUNCTION 'BAPI_CUSTOMERRETURN_CREATE'* EXPORTING* return_header_in = st_bapisdhd1* return_header_inx = st_bapisdhd1x* logic_switch = st_logic_switch* IMPORTING* salesdocument = g_vbeln_criado* TABLES* return = tbl_return* return_items_in = tbl_bapisditm* return_items_inx = tbl_bapisditmx* return_conditions_in = tbl_bapicond* return_partners = tbl_bapiparnr* return_schedules_in = tbl_bapischdl* return_schedules_inx = tbl_bapischdlx. " Encontrou erro entao mostra APPEND LINES OF tbl_return_bapi TO tbl_return.*** Mensagens de sucesso! IF g_vbeln_criado IS NOT INITIAL. DELETE tbl_return WHERE type EQ 'S' OR type EQ 'W'. CLEAR tbl_return. tbl_return-id = 'SU'. tbl_return-type = 'S'. tbl_return-number = '000'. tbl_return-message_v1 = g_vbeln_criado. tbl_return-message_v2 = 'Ordem de devolucao gerada com Sucesso!'. APPEND tbl_return. ENDIF. " Mostra mensagem de sucesso CALL FUNCTION 'C14ALD_BAPIRET2_SHOW' TABLES i_bapiret2_tab = tbl_return. " Nao encontrou erro entao comita IF g_vbeln_criado IS NOT INITIAL. " Mostrar andamento na barra de status CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' EXPORTING percentage = 70 text = 'Ordem de devolucao gerada - atualizando tabelas'. " Comit CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. " Atualizar tabela nf devolucoes gw_pre_registro-vbeln = g_vbeln_criado. gw_pre_registro-situacao = 'L'. MODIFY zsdt016 FROM gw_pre_registro. " 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. PERFORM recarrega_dados_ordem. " Carregar dados diretamente da Ordem ENDIF. sy-ucomm = 'COCKPIT_FC2'. " Chamar tela documento SD PERFORM chama_cockpit_tab. " Pular para TAB 'Lancar' CALL METHOD cl_gui_cfw=>flush. ENDIF. " Mostrar andamento na barra de status* CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'* EXPORTING* percentage = 70* text = 'Ordem de devolucao gerada - atualizando condicoes'.* " Atualiza nova ordem criada com condicoes de preco* PERFORM atualiza_ordem_devolucao. " Mostrar andamento na barra de status CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' EXPORTING percentage = 95 text = 'Processo finalizado'.ENDFORM. " chamar_bapi_ordem_devolucao*&---------------------------------------------------------------------** Calcula o campo offset com as condicoes de preco*----------------------------------------------------------------------*FORM chamar_calculo_offset . DATA lv_tabix TYPE sy-index. DATA: st_head_chg LIKE bapisdh1x, st_logic_switch TYPE bapisdls. st_logic_switch-pricing = 'B'.* st_logic_switch-cond_handl = 'X'. FREE tbl_return. " Mostrar andamento na barra de status CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' EXPORTING percentage = 25 text = 'Calculando campo OFFSET'.* CALL FUNCTION 'SD_SALESDOCUMENT_CREATE' EXPORTING sales_header_in = st_bapisdhd1 sales_header_inx = st_bapisdhd1x logic_switch = st_logic_switch business_object = 'BUS2102' testrun = 'X' TABLES return = tbl_return sales_items_in = tbl_bapisditm sales_items_inx = tbl_bapisditmx sales_partners = tbl_bapiparnr sales_schedules_in = tbl_bapischdl sales_schedules_inx = tbl_bapischdlx sales_conditions_in = tbl_bapicond sales_conditions_inx = tbl_bapicondx conditions_ex = tbl_bapicond_ex.* CALL FUNCTION 'BAPI_CUSTOMERRETURN_CREATE'* EXPORTING* return_header_in = st_bapisdhd1* return_header_inx = st_bapisdhd1x* logic_switch = st_logic_switch* testrun = 'X'* TABLES* return = tbl_return* return_items_in = tbl_bapisditm* return_items_inx = tbl_bapisditmx* return_conditions_in = tbl_bapicond* return_partners = tbl_bapiparnr* return_schedules_in = tbl_bapischdl* return_schedules_inx = tbl_bapischdlx.*** Mensagens de erro! READ TABLE tbl_return WITH KEY type = 'E'. IF sy-subrc EQ 0. DELETE tbl_return WHERE type EQ 'S'. ELSE. " Alterando tabela valida com subtotais LOOP AT gt_itens_valida INTO gs_itens_valida. lv_tabix = sy-tabix. READ TABLE tbl_bapicond_ex WITH KEY itm_number = gs_itens_valida-kposn cond_type = 'SKTO'. IF sy-subrc EQ 0. gs_itens_valida-kawrt = tbl_bapicond_ex-conbaseval." * '0.1'. MODIFY gt_itens_valida FROM gs_itens_valida INDEX lv_tabix. ENDIF. ENDLOOP. ENDIF. DELETE tbl_return WHERE type EQ 'S'. " Mostra mensagem de sucesso CALL FUNCTION 'C14ALD_BAPIRET2_SHOW' TABLES i_bapiret2_tab =