terça-feira, 12 de novembro de 2024

Mensagens de LOG

Recuperando texto da mensagem


lt_log = VALUE #( BASE lt_log

FOR ls_return IN lt_return

( ovret = lr_monfat->ovRet

fatret = lr_monfat->faturaRet

msgid = ls_return-id

msgty = ls_return-type

msgno = ls_return-number

message = cl_bs_soa_message_container=>get_msg_text( is_applmsg = VALUE #( type = ls_return-type

id = ls_return-id

number = ls_return-number

message_v1 = ls_return-message_v1

message_v2 = ls_return-message_v2

message_v3 = ls_return-message_v3

message_v4 = ls_return-message_v4

) ) ) ).




Cria LOG SLG1


METHOD set_log.


DATA lv_error_msg TYPE string.


CHECK it_return[] IS NOT INITIAL.


TRY.


" Create a new Application Log

DATA(lo_log) = cl_bali_log=>create( ).


" Add a header to the log

lo_log->set_header( header = cl_bali_header_setter=>create( object = c_log-object

subobject = c_log-subobject

external_id = CONV #( is_monfat-ovRet ) ) ).


LOOP AT it_return REFERENCE INTO DATA(lr_return).

"WHERE type = 'E'.


* rs_return = VALUE #( id = 'ZSD' type = 'E' number = '015' ).


" Add a message as item to the log

DATA(lo_message) = cl_bali_message_setter=>create( severity = lr_return->type "if_bali_constants=>c_severity_error

id = lr_return->id

number = lr_return->number

variable_1 = lr_return->message_v1

variable_2 = lr_return->message_v2

variable_3 = lr_return->message_v3

variable_4 = lr_return->message_v4

).

lo_log->add_item( item = lo_message ).


ENDLOOP.


" Save the log into the database

cl_bali_log_db=>get_instance( )->save_log( log = lo_log ).


CATCH cx_bali_not_possible INTO DATA(lx_not_possible).

lv_error_msg = lx_not_possible->get_text( ).


CATCH cx_bali_runtime INTO DATA(lx_runtime).

lv_error_msg = lx_runtime->get_text( ).


ENDTRY.


ENDMETHOD.


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


elimina log

METHOD delete_log.


TRY.

DATA(lo_filter) = cl_bali_log_filter=>create(

)->set_create_info( user = sy-uname

)->set_descriptor( object = c_log-object

subobject = c_log-subobject

external_id = CONV balnrext( iv_ordemvenda ) ).


DATA(lv_data_final) = utclong_current( ).

DATA(lv_data_inicio) = utclong_add( val = lv_data_final

days = '30-' ).

lo_filter->set_time_interval( start_time = lv_data_inicio

end_time = lv_data_final ).


lo_filter->set_maximum_log_number( max_log_number = 15 ).


DATA(lt_log_table) = cl_bali_log_db=>get_instance( )->load_logs_w_items_via_filter( filter = lo_filter ).


CATCH cx_bali_runtime INTO DATA(lx_exception). "##NEEDED

DATA(lv_error_msg) = lx_exception->get_text( ).

RETURN.


ENDTRY.


LOOP AT lt_log_table INTO DATA(lo_log).

cl_bali_log_db=>get_instance( )->delete_log( lo_log ).

ENDLOOP..


COMMIT WORK AND WAIT.



ENDMETHOD.



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


retorno de mensagem.


METHOD get_log.


DATA lv_cont TYPE n LENGTH 3.


TRY.

DATA(lo_filter) = cl_bali_log_filter=>create(

)->set_create_info( user = sy-uname

)->set_descriptor( object = c_log-object

subobject = c_log-subobject

external_id = CONV balnrext( iv_ordemvenda ) ).


DATA(lv_data_final) = utclong_current( ).

DATA(lv_data_inicio) = utclong_add( val = lv_data_final

days = '30-' ).

lo_filter->set_time_interval( start_time = lv_data_inicio

end_time = lv_data_final ).


lo_filter->set_maximum_log_number( max_log_number = 15 ).


DATA(lt_log_table) = cl_bali_log_db=>get_instance( )->load_logs_w_items_via_filter( filter = lo_filter ).


CATCH cx_bali_runtime INTO DATA(lx_exception). "##NEEDED

RETURN.


ENDTRY.


* sort lo_log_table by log_timestamp.


LOOP AT lt_log_table INTO DATA(lo_log). "#EC CI_NESTED


" Get log header and output attributes of the header

TRY.


DATA(lo_header) = lo_log->get_header( ).


ADD 1 TO lv_cont.


* APPEND INITIAL LINE TO rt_return ASSIGNING FIELD-SYMBOL(<lf_return>).

* <lf_return> = VALUE #( id = 'ZSD' type = 'E' number = '000'

* message_v1 = lv_cont "|{ lv_cont }- Data/hora log:|

* message_v2 = lo_header->log_timestamp

* message = |Data/hora log:| && ##NO_TEXT

* |{ lo_header->log_timestamp }| ).



" Get all items and output some data which exist in all item categories

DATA(lt_item_table) = lo_log->get_all_items( ).

LOOP AT lt_item_table INTO DATA(ls_item_entry). "#EC CI_NESTED


ADD 1 TO lv_cont.


" Output attributes which are specific for messages and exceptions

IF ls_item_entry-item->category = if_bali_constants=>c_category_message.


DATA(lo_message_ref) = CAST if_bali_message_getter( ls_item_entry-item ).

APPEND INITIAL LINE TO rt_return ASSIGNING FIELD-SYMBOL(<lf_return>).

<lf_return> = VALUE #( id = lo_message_ref->id

type = lo_message_ref->severity

number = lo_message_ref->number

message_v1 = lv_cont "lo_message_ref->variable_1

message_v2 = lo_message_ref->variable_2

message_v3 = lo_message_ref->variable_3

message_v4 = lo_message_ref->variable_4

* message = |{ lv_cont }- { lo_message_ref->get_message_text( ) }| ).

message = lo_message_ref->get_message_text( ) ).


ENDIF.


ENDLOOP.


SORT rt_return BY message_v1 DESCENDING. "#EC CI_SORTLOOP


CATCH cx_bali_runtime INTO DATA(lx_exc). "##NEEDED

DATA(lv_error_msg) = lx_exc->get_text( ).


ENDTRY.


ENDLOOP.


ENDMETHOD.


terça-feira, 8 de outubro de 2024

RAP - Ordenando exibição listreport

-- Annotation presentationVariant


 @Metadata.layer: #CORE

@UI.headerInfo:{ typeName: 'Monitor teste',

typeNamePlural: 'Monitor teste',

title:{ type: #STANDARD, label: 'Monitor teste', value: 'ordemVenda' } }


@UI.presentationVariant: [{ sortOrder: [{ by: 'ordem?Venda', direction: #DESC }], visualizations: [{type: #AS_LINEITEM }] }]


annotate entity ZC_Teste1 with

{


@UI.facet: [



- Detalhe q não funciona com tabela tipo ResponsiveTable 




segunda-feira, 7 de outubro de 2024

AMDP - Table function - fazendo split de uma string em colunas diferentes

Dados da tabela ZPARAMS





RESULT select mandt as client,

substr_regexpr('[^;]+' IN "LOW" OCCURRENCE 1 ) AS "BSART",

substr_regexpr('[^;]+' IN "LOW" OCCURRENCE 2 ) AS "ITMTYP"

from zparams

where package = 'ZTESTE'

and parameter = 'TIPO_PEDIDO';



RESULTADO


segunda-feira, 26 de agosto de 2024

BAPI_ACC_DOCUMENT_POST - Extension - correção de erro DBSQL_REDIRECT_INCONSISTENCY

 - Incluir campo na estrutura CI_COBL da estrutura ACCBAPI_S4EXT_DATA, isso se o campo não existir na ACCIT pq tem campos standards q está na BSEG e as vezes não existem na ACCIT











2384731 - Correction program: COEP and replacement object V_COEP have different number of columns

2686694 - How-To: MSEG - DBSQL_REDIRECT_INCONSISTENCY






terça-feira, 9 de julho de 2024

RAP - Visualizar 2 views na mesma página do ListReport

 - No meu caso são 2 CDS, 1 com informações de cabeçalho e outra de itens.

Fica como se fossem 2 abas





- Criar as CDSs normalmente sem relação nenhum, criei uma projection view e metadata 1 para cada view.












- Ao criar o SERVICE DEFINITION, adicionar as 2 projections criada







- Criar o service binding e publicar

- Criar a aplicação no VS code. E agora a diversão começa

Utilizar a modificação da aplicação pelo Fiori Guide Development





Selecionar opção para múltipla seleção 







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

MANIFEST.JSON

    "sap.ui.generic.app": {
        "_version": "1.3.0",
        "settings": {
            "forceGlobalRefresh": false,
            "objectPageHeaderType": "Dynamic",
            "considerAnalyticalParameters": true,
            "showDraftToggle": false
        },
        "pages": {
            "ListReport|ZSZK_TEST_VAL_C": {
                "entitySet": "ZSZK_TEST_VAL_C",
                "component": {
                    "name": "sap.suite.ui.generic.template.ListReport",
                    "list": true,
                    "settings": {
                        "condensedTableLayout": true,
                        "smartVariantManagement": true,
                        "enableTableFilterInPageVariant": true,
                        "filterSettings": {
                            "dateSettings": {
                                "useDateRange": true
                            }
                        },
                        "quickVariantSelectionX": {
                            "enableAutoBinding": false,
                            "variants": {
                                "Header": {
                                    "key": "tab0",
                                    "annotationPath": "com.sap.vocabularies.UI.v1.SelectionPresentationVariant#Header",
                                    "entitySet": "ZSZK_TEST_VAL_C"
                                },
                                "Item": {
                                    "key": "tab1",
                                    "annotationPath": "com.sap.vocabularies.UI.v1.SelectionPresentationVariant#Item",
                                    "entitySet": "ZSZK_TEST_VAL_IT_C"
                                }
                            },
                            "showCounts": false
                        }
                    }
                },
                "pages": {
                    "ObjectPage|ZSZK_TEST_VAL_C": {
                        "entitySet": "ZSZK_TEST_VAL_C",
                        "defaultLayoutTypeIfExternalNavigation": "MidColumnFullScreen",
                        "component": {
                            "name": "sap.suite.ui.generic.template.ObjectPage"
                        }
                    }
                }
            }
        }
    },








ANNOTATION.XML

<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
    <edmx:Reference Uri="https://sap.github.io/odata-vocabularies/vocabularies/UI.xml">
        <edmx:Include Namespace="com.sap.vocabularies.UI.v1" Alias="UI"/>
    </edmx:Reference>
    <edmx:Reference Uri="/sap/opu/odata/sap/ZSZK_TESTE_VAL/$metadata">
        <edmx:Include Namespace="cds_zszk_teste_val"/>
    </edmx:Reference>
    <edmx:DataServices>
        <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="local">
            <Annotations Target="cds_zszk_teste_val.ZSZK_TEST_VAL_CType">
                <Annotation Term="UI.SelectionPresentationVariant" Qualifier="Header">
                    <Record Type="UI.SelectionPresentationVariantType">
                        <PropertyValue Property="Text" String="Header de dados"/>
                        <PropertyValue Property="SelectionVariant">
                            <Record Type="UI.SelectionVariantType">
                                <PropertyValue Property="SelectOptions">
                                    <Collection>
                                        <Record Type="UI.SelectOptionType">
                                            <PropertyValue Property="PropertyName" PropertyPath="Inbounddeliveryid"/>
                                            <PropertyValue Property="Ranges">
                                                <Collection>
                                                    <Record Type="UI.SelectionRangeType">
                                                        <PropertyValue Property="Sign" EnumMember="UI.SelectionRangeSignType/I"/>
                                                        <PropertyValue Property="Option" EnumMember="UI.SelectionRangeOptionType/NE"/>
                                                        <PropertyValue Property="Low" String="0"/>
                                                    </Record>
                                                </Collection>
                                            </PropertyValue>
                                        </Record>
                                    </Collection>
                                </PropertyValue>
                            </Record>
                        </PropertyValue>
                        <PropertyValue Property="PresentationVariant">
                            <Record Type="UI.PresentationVariantType">
                                <PropertyValue Property="Visualizations">
                                    <Collection>
                                        <AnnotationPath>@UI.LineItem#Header</AnnotationPath>
                                    </Collection>
                                </PropertyValue>
                            </Record>
                        </PropertyValue>
                    </Record>
                </Annotation>
            </Annotations>

            <Annotations Target="cds_zszk_teste_val.ZSZK_TEST_VAL_IT_CType">
                <Annotation Term="UI.SelectionPresentationVariant" Qualifier="Item">
                    <Record Type="UI.SelectionPresentationVariantType">
                        <PropertyValue Property="Text" String="Item"/>
                        <PropertyValue Property="SelectionVariant">
                            <Record Type="UI.SelectionVariantType">
                                <PropertyValue Property="SelectOptions">
                                    <Collection>
                                        <Record Type="UI.SelectOptionType">
                                            <PropertyValue Property="PropertyName" PropertyPath="Iddoc"/>
                                            <PropertyValue Property="Ranges">
                                                <Collection>
                                                    <Record Type="UI.SelectionRangeType">
                                                        <PropertyValue Property="Sign" EnumMember="UI.SelectionRangeSignType/I"/>
                                                        <PropertyValue Property="Option" EnumMember="UI.SelectionRangeOptionType/NE"/>
                                                        <PropertyValue Property="Low" String="0"/>
                                                    </Record>
                                                </Collection>
                                            </PropertyValue>
                                        </Record>
                                    </Collection>
                                </PropertyValue>
                            </Record>
                        </PropertyValue>
                        <PropertyValue Property="PresentationVariant">
                            <Record Type="UI.PresentationVariantType">
                                <PropertyValue Property="Visualizations">
                                    <Collection>
                                        <AnnotationPath>@UI.LineItem#Item</AnnotationPath>
                                    </Collection>
                                </PropertyValue>
                            </Record>
                        </PropertyValue>
                    </Record>
                </Annotation>
            </Annotations>            
        </Schema>
    </edmx:DataServices>
</edmx:Edmx>

sexta-feira, 5 de julho de 2024

RAP - Publishing ODATA V4

SAP NOTE

 3101976 - Publishing OData V4 service is throwing error: Publishing of XXXXXXXXXX in Customizing cli...


Create a RAP BO including a V4 service binding using ADT

Activate the Service Binding (this will create a service group) (but do not use the button "publish locally)

Use transaction /n/iwfnd/v4_admin to publish the service group

segunda-feira, 17 de junho de 2024

Limpeza buffer de tabela - Problema na visualização do titulo do campo mesmo alterando o elemento de dados

 Fato curioso, eu alterei alguns elementos de dados de uma tabela, quando eu visualizava na SE16N a descrição dos campos na primeira tela de parâmetros estava correta mas ao listar os dados no ALV o título não conferia com os que tinham sido alterado.

Para resolver só consegui usando esse comando no campo do ok-code, vi isso em outro blog e funcionou

  • /$sync (limpeza do buffer);