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.






segunda-feira, 3 de novembro de 2025

RAP - Deixar coluna da lista com somatório - somente para oData V2

Para oDataV4 , ocorre um erro ao tentar carregar os dados. Se procurar no SDN tem um post sobre esse erro e uma resposta que no V4 somente utilizando as annotations para analytics, link abaixo


https://community.sap.com/t5/technology-q-a/rap-view-entity-analytical-table-with-subtotals-totals-in-list-report-sap/qaq-p/14118877


=== VIEW ENTITY

 @AbapCatalog.viewEnhancementCategory: [#NONE]

@AccessControl.authorizationCheck: #NOT_REQUIRED

@EndUserText.label: 'TESTE'

@Metadata.ignorePropagatedAnnotations: true

@ObjectModel.usageType:{

serviceQuality: #X,

sizeCategory: #S,

dataClass: #MIXED

}



define root view entity ZI_SZK1

as select from zszk_tab

{


key matnr as Matnr,

key status as Status,

waers as Waers,

@Semantics.amount.currencyCode: 'waers'

valor as Valor,

valor2 as Valor2

}




@AccessControl.authorizationCheck: #NOT_REQUIRED

@EndUserText.label: 'Projectoi'

@Metadata.ignorePropagatedAnnotations: true

@Analytics.dataCategory: #CUBE


@UI.presentationVariant : [{

groupBy : [ 'Matnr' ],

total : [ 'Valor' ],

visualizations: [{

type: #AS_LINEITEM,

element: 'Valor'

}]

}]


=== PROJECTION


define root view entity ZC_SZK1

provider contract transactional_query

as projection on ZI_SZK1

{


@UI.facet: [


{

purpose: #STANDARD,

type: #IDENTIFICATION_REFERENCE,

targetQualifier: 'DPBP',

position: 10


}]

@UI.lineItem: [{ position: 10 }]

@UI.identification: [{ position: 10 }]

key Matnr,

@UI.lineItem: [{ position: 20 }]

@UI.identification: [{ position: 20 }]

key Status,

// @UI.lineItem: [{ position: 30 }]

// @UI.identification: [{ position: 30 }]

@Semantics.currencyCode: true

Waers,

@UI.lineItem: [{ position: 40 }]

@UI.identification: [{ position: 40 }]

@Semantics.amount.currencyCode: 'Waers'

@Aggregation.default: #SUM

Valor,

@UI.lineItem: [{ position: 50 }]

@UI.identification: [{ position: 50 }]

@Aggregation.default: #SUM

Valor2

}



No VS Code selecionar a opção de LIST REPORT PAGE,  na seleção do tipo da tabela selecionar o Analytical