tbl_return. " Mostrar andamento na barra de status CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' EXPORTING percentage = 70 text = 'Campo OFFSET calculado com sucesso'.ENDFORM.*&---------------------------------------------------------------------** Atualiza nova ordem criada com as condicoes de preco*----------------------------------------------------------------------*FORM atualiza_ordem_devolucao . CHECK g_vbeln_criado IS NOT INITIAL. PERFORM pegar_condicao_preco. PERFORM monta_condicoes_bapi. PERFORM chamar_bapi_muda_ord_devolucao. CLEAR g_vbeln_criado.ENDFORM. " atualiza_ordem_devolucao*&---------------------------------------------------------------------** Pegar as condicoes de preco geradas na ordem anteriormente*----------------------------------------------------------------------*FORM pegar_condicao_preco .* E preciso obter manualmente os precos relevantes condicoes que o BAPI* BAPISDORDER_GETDETAILEDLIST causa problemas quando chamamos o BAPI* BAPI_SALESORDER_CREATEFROMDAT2 e BAPI_SALESORDER_CHANGE (eu acho que* isto e devido ao fato de estes BAPIs pertencem a mesma funcao* Grupo e deve haver algumas estruturas comuns que nao sao apuradas* fazendo-nos todos os tipos de dor quando tentamos e ligue para o proximo BAPI) DATA: tbl_konv TYPE STANDARD TABLE OF konv WITH HEADER LINE. DATA: tbl_komv TYPE STANDARD TABLE OF komv WITH HEADER LINE. DATA: tbl_vbak TYPE STANDARD TABLE OF vbak WITH HEADER LINE.* Pricing Condition Master DATA: BEGIN OF tbl_t685a OCCURS 0, kschl LIKE t685a-kschl, kaend_wrt LIKE t685a-kaend_wrt, END OF tbl_t685a. SELECT * INTO TABLE tbl_vbak FROM vbak WHERE vbeln = g_vbeln_criado. READ TABLE tbl_vbak INDEX 1. SELECT * INTO TABLE tbl_konv FROM konv WHERE knumv = tbl_vbak-knumv AND kschl = 'PR00'. CHECK sy-subrc EQ 0.* We now need to make sure we only bring across the Condition Types that* are EDITABLE. If we bring across non editable conditions (such as* 'ZPR1') the Change Sales Order BAPI will fail SELECT kschl kaend_wrt INTO TABLE tbl_t685a FROM t685a FOR ALL ENTRIES IN tbl_konv WHERE kappl EQ 'V' AND "Vendas kschl EQ tbl_konv-kschl AND kaend_wrt EQ 'X' ."AND "Valor e editavel* kmanu NE 'D'. "Processado manualmente* Prepara para Binary Search SORT tbl_t685a BY kschl. LOOP AT tbl_konv. READ TABLE tbl_t685a WITH KEY kschl = tbl_konv-kschl BINARY SEARCH. IF sy-subrc EQ 0. MOVE-CORRESPONDING tbl_konv TO tbl_komv. APPEND tbl_komv. ENDIF. ENDLOOP. CHECK NOT tbl_komv[] IS INITIAL.* Maper KOMV dentro da estrutura BAPISDCOND CALL FUNCTION 'MAP_INT_TO_EXT_STRUCTURE' TABLES fxvbak = tbl_vbak fxkomv = tbl_komv fxbapikomv = tbl_bapisdcond EXCEPTIONS entry_missing = 1 OTHERS = 2.ENDFORM. " pegar_condicao_preco*&---------------------------------------------------------------------** Poe os novos precos na condicao PR00*----------------------------------------------------------------------*FORM monta_condicoes_bapi . LOOP AT tbl_bapisdcond. CLEAR tbl_bapicond. READ TABLE gt_itens_valida INTO gs_itens_valida WITH KEY kposn = tbl_bapisdcond-itm_number. IF sy-subrc EQ 0. MOVE-CORRESPONDING tbl_bapisdcond TO tbl_bapicond. tbl_bapicond-cond_updat = 'X'. tbl_bapicond-cond_value = gs_itens_valida-sap_netpr. tbl_bapicond-cond_unit = gs_itens_valida-sap_meins. APPEND tbl_bapicond. CLEAR tbl_bapicondx. tbl_bapicondx-itm_number = tbl_bapicond-itm_number. tbl_bapicondx-cond_st_no = tbl_bapicond-cond_st_no. tbl_bapicondx-cond_count = tbl_bapicond-cond_count. tbl_bapicondx-cond_type = tbl_bapicond-cond_type. tbl_bapicondx-updateflag = 'U'. tbl_bapicondx-cond_value = 'X'. tbl_bapicondx-cond_unit = 'X'. APPEND tbl_bapicondx. ENDIF. ENDLOOP.ENDFORM. " monta_condicoes_bapi*&---------------------------------------------------------------------** Chamar BAPI para atualizar valores da ordem de venda*----------------------------------------------------------------------*FORM chamar_bapi_muda_ord_devolucao . DATA: st_head_chg LIKE bapisdh1x, st_logic_switch TYPE bapisdls. CHECK NOT g_vbeln_criado IS INITIAL. st_head_chg-updateflag = 'U'. st_logic_switch-pricing = 'B'.* st_logic_switch-cond_handl = 'X'. CALL FUNCTION 'BAPI_SALESORDER_CHANGE' EXPORTING salesdocument = g_vbeln_criado order_header_inx = st_head_chg logic_switch = st_logic_switch TABLES return = tbl_return_chg conditions_in = tbl_bapicond conditions_inx = tbl_bapicondx. " Encontrou erro entao mostra LOOP AT tbl_return_chg WHERE type = 'X'. MESSAGE tbl_return_chg-message TYPE 'I'. ENDLOOP. " Nao encontrou erro entao comita READ TABLE tbl_return_chg TRANSPORTING NO FIELDS WITH KEY type = 'E'. IF sy-subrc NE 0. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. ENDIF.ENDFORM. " chamar_bapi_muda_ord_devolucao*&---------------------------------------------------------------------**