terça-feira, 25 de novembro de 2025

Processamento de execução em background task esperando por commit

 FUNCTION zfmmm_inforecord_maintain_m

IMPORTING

VALUE(iv_task) TYPE string

TABLES

ct_eina TYPE mewieina_mig_t OPTIONAL

ct_einax TYPE mewieinax_t OPTIONAL

ct_eine TYPE mewieine_t OPTIONAL

ct_einex TYPE mewieinex_t OPTIONAL

ct_txt_lines TYPE mewipirtext_tt OPTIONAL

ct_cond_validity TYPE mewivalidity_tt OPTIONAL

ct_condition TYPE mewicondition_tt OPTIONAL

ct_cond_scale_value TYPE mewiscaleval_tt OPTIONAL

ct_cond_scale_quan TYPE mewiscalequan_tt OPTIONAL

ct_return TYPE fs4mig_t_bapiret2 OPTIONAL.




DATA: lt_return TYPE fs4mig_t_bapiret2.


DATA: lv_infnr TYPE eina-infnr.


gv_esperar = abap_false.


CALL FUNCTION 'ZFMMM_INFORECORD_MAINTAIN_MULT'

DESTINATION 'NONE'

STARTING NEW TASK iv_task

PERFORMING f_recebe_dados_operacao ON END OF TASK

TABLES

ct_eina = ct_eina

ct_einax = ct_einax

ct_eine = ct_eine

ct_einex = ct_einex

ct_cond_validity = ct_cond_validity

ct_condition = ct_condition

ct_return = ct_return.


WAIT FOR ASYNCHRONOUS TASKS

UNTIL gv_esperar = abap_true.


*

ct_return[] = gt_return[].


CLEAR: lv_infnr.

READ TABLE ct_return ASSIGNING FIELD-SYMBOL(<lf_return>)

WITH KEY type = 'S'

id = '06'

number = '331'.

IF sy-subrc = 0.

lv_infnr = <lf_return>-message_v1.

DO 10 TIMES.

SELECT COUNT(*)

FROM eina

INNER JOIN eine

ON eina~infnr = eine~infnr

WHERE eina~infnr = lv_infnr.

IF sy-subrc = 0.

EXIT.

ENDIF.

WAIT UP TO 1 SECONDS.

ENDDO.

ENDIF.


ENDFUNCTION.





=================================

FORM f_recebe_dados_operacao USING iv_taskname.

DATA: lt_return TYPE TABLE OF fs4mig_s_bapiret2.


CLEAR gt_return.


RECEIVE RESULTS FROM FUNCTION 'ZFMMM_INFORECORD_MAINTAIN_MULT'

TABLES

ct_return = lt_return


EXCEPTIONS

resource_failure = 1

system_failure = 2

communication_failure = 3.


APPEND LINES OF lt_return TO gt_return.

ENDFORM.






Nenhum comentário:

Postar um comentário