segunda-feira, 4 de dezembro de 2023

DUMP VBFA - duplicated key - BAPI BAPI_SALESORDER_CREATEFROMDAT2

 - Caso estranho onde tenho um programa que executa uma remessa VL01NO em batch input e depois a criação de ordem de venda pela BAPI BAPI_SALESORDER_CREATEFROMDAT2, ocorre um DUMP de chave duplicada na atualização da VBFA


Coisa muita estranha, onde analisando o DUMP percebi que nessa tabela DA_XVBFAI no conteúdo tinha 2 registros onde 1 era a ordem em si q estava criando e a outra a remessa que tinha criado anteriormente no batch input.   

Pesquisando no SDN achei o mesmo problema, que se resolveu utilizando a função RV_DELIVERY_INIT antes da execução da BAPI



segunda-feira, 6 de novembro de 2023

CSD/AMDP - Erro ao criar AMDP, CDS standard com erro de mandante especifico deve ser informado

 Informar os parâmetros.

@ClientHandling.type: #CLIENT_DEPENDENT
@ClientHandling.algorithm: #SESSION_VARIABLE
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Teste'
define table function ZZZ_TESTE
  with parameters
    @Environment.systemField: #CLIENT
    client       : abap.clnt,
    p_dtbase     : datum,
    p_where_part : abap.char( 500 ),
    p_where_trfi : abap.char( 255 )
returns
{
  client     : abap.clnt;
  rfha       : tb_rfha;
  bukrs      : bukrs;
  KONTRH     : tb_kunnr_new;
  tp_prod    : vvsart;
  tp_trfi    : tb_sfhaart;
  observacao : zdetrm_observacao;
  banco      : zdt_bankl;
  tp_mov     : tb_sfhazba;
  ano        : gjahr;
  valor      : tb_bzbetr;
}
implemented by method
  zcl_cds_teste=>execute_db;



sexta-feira, 15 de setembro de 2023

CL_GUI_ALV_GRID - TOP_OF_PAGE - CL_DD_DOCUMENT - METHOD ADD_TABLE

== GLOBAL VARIABLE
 DATA: o_split_dev       TYPE REF TO cl_gui_splitter_container,
           o_dyndoc_id       TYPE REF TO cl_dd_document,
           o_cont_dev_top    TYPE REF TO cl_gui_container,
           o_cont_dev_list   TYPE REF TO cl_gui_container.


=================================
=== > CREATE ALV
    o_alv_dev->set_table_for_first_display(
         EXPORTING
          "i_save =
             is_layout = ls_layout
             it_toolbar_excluding = lt_exc_toolbar
         CHANGING
             it_outtab  = t_dev
             it_fieldcatalog = lt_fcat
         EXCEPTIONS
             invalid_parameter_combination = 1
             program_error  = 2
             too_many_lines = 3 ).

    DATA(lo_alv_event) = NEW lcl_handle_events( ).
    SET HANDLER lo_alv_event->top_of_page FOR o_alv_dev.

    CREATE OBJECT o_dyndoc_id
      EXPORTING
        style = 'ALV_GRID'.
*
* Initializing document
    CALL METHOD o_dyndoc_id->initialize_document.
*
* Processing events
    CALL METHOD o_alv_dev->list_processing_events
      EXPORTING
        i_event_name = 'TOP_OF_PAGE'
        i_dyndoc_id  = o_dyndoc_id.

==================================================
==== > HANDLE METHOD TOP OF PAGE
  METHOD top_of_page.

    DATA lt_element TYPE sdydo_object_table.
    DATA lv_qtd_c TYPE sdydo_text_element .

    o_dyndoc_id->add_table(
    EXPORTING
    no_of_columns = 2
    IMPORTING
    table = DATA(lo_table)
    tablearea = DATA(lo_table_area) ).

    lo_table->add_column( EXPORTING width = '40%' IMPORTING column = DATA(lo_col1) ).
    lo_table->add_column( EXPORTING width = '60%' IMPORTING column = DATA(lo_col2) ).

    me->get_saldo_dev( ).

    lo_col1->add_text( text = 'Saldo do estoque'
                      sap_fontsize = cl_dd_document=>large ).

    WRITE gs_dev_cab-saldo_est TO lv_qtd_c.
    lo_col2->add_text( text = |{ lv_qtd_c ALIGN = RIGHT }| sap_fontsize = cl_dd_document=>large ).

    lo_table->new_row( ).

    lo_col1->add_text( text = 'Total Planejado'
                      sap_fontsize = cl_dd_document=>large ).

    WRITE gs_dev_cab-total_plan TO lv_qtd_c.
    lo_col2->add_text( text = |{ lv_qtd_c ALIGN = RIGHT }| sap_fontsize = cl_dd_document=>large ).

    o_dyndoc_id->merge_document( ).

    CALL METHOD o_dyndoc_id->display_document
      EXPORTING
        reuse_control = abap_true
        parent        = o_cont_dev_top.

  ENDMETHOD.

=========== OUTPUT 




terça-feira, 18 de julho de 2023

Calling method from another class from another program

PROGRAM 1

 REPORT y_test_prog1.

DATA lv_cc TYPE bkpf-bukrs.

CLASS lcl_local_class DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS :
      cc_code IMPORTING lv_cc TYPE bkpf-bukrs.
ENDCLASS.

CLASS lcl_local_class IMPLEMENTATION.
  METHOD cc_code.
    IF lv_cc = ‘1000’.
      WRITE  lv_cc.
    ELSE.
      WRITE : ‘Worked’ , lv_cc.
    ENDIF.
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  lv_cc = ‘1000’.
  CALL METHOD lcl_local_class=>cc_code
    EXPORTING
      lv_cc = lv_cc.

PROGRAM 2

REPORT y_test_prog2.

PARAMETER  lv_cc TYPE bkpf-bukrs.

DATA : go_test         TYPE REF TO object,
       ge_abs_typename TYPE string
          VALUE ‘\PROGRAM=Y_TEST_PROG1\CLASS=LCL_LOCAL_CLASS’.

START-OF-SELECTION.
  CREATE OBJECT go_test TYPE (ge_abs_typename).
BREAK-POINT.
  CALL METHOD go_test->(‘CC_CODE’)
    EXPORTING
      lv_cc = lv_cc.

quarta-feira, 5 de julho de 2023

CL_GUI_TEXT_EDITOR - Get text using method GET_TEXTSTREAM

 After call metho GET_TEXTSTREAM, call the method flush

Example.

    IF o_editor_test IS BOUND.

      o_editor_test->get_textstreamIMPORTING text = DATA(lv_text) ).
      cl_gui_cfw=>flush).
    ENDIF.

Eclipse ABAP - shortcuts

F3 - Igual F2 no SAPGUI - entra no método ou perform

F2 - Exibe campos de estrutura/função/tabelas etc.

CTRL+F3 = Ativar 

CTRL+SHIFT+F3 = Ativar vários objetos

F8 = F8 no SAPGUI - executa programa

CTRL+SHIFT+< = Comentar código 

CTRL+SHIFT+> = Descomentar código 

CTRL+SHIFT+X = upper case

CTRL+SHIFT+Y = lower case

CTRL+1 = opções para implementar, renomear, excluir método

ALT+SHIFT+R = Renomeia uma variável de qualquer tipo em todos os lugares onde a variável é  utilizado no mesmo objeto (as vezes dá pau mas funciona)

CTRL + O  - Lista de métodos ou subrotinas para navegação

CTRL+SHIFT+G - Lista de utilização do objeto

Navegar para elemento de texto.







Alt+F2     -     Shows the signature of the method you are currently editing



Tab/Shift+Tab     -     When selecting a multiple lines of code, Tab indents the selection and Shift+Tab decreases the indent

CTRL+SHIFT+L - This open a list with all shortcuts available.

https://blogs.sap.com/2022/12/06/abap-cheat-sheets/


from blog

https://blogs.sap.com/2013/11/21/useful-keyboard-shortcuts-for-abap-in-eclipse/



Editing source code:

ShortcutWhat it will do
CTRL+DDeletes the selected codeline
CTRL+SHIFT+DELETEDeletes the content from the cursor position to the end of the line
CTRL+DELETEDeletes the next word in the editor
CTRL+BACKSPACEDeletes the previous word in the editor
ALT+UP/DOWNMoves the selected codelines up/down in the editor
CTRL+ALT+UP/DOWNDuplicates Codelines before/after the selected codeline
CTRL+UP/DOWNScrolls Line up/down
SHIFT+ENTERAdds a new line below the current line and positions the cursor in that line
CTRL+SHIFT+ENTERAdds a new line above the current line and positions the cursor in that line
CTRL+ZUndo changes
ALT+SHIFT+RRename the selected object, e.g. variable, method, class
CTRL+1Opens Quickfix/Quickassist Dialog on the selected element
CTRL+7Comments/Uncomments selected code in the editor
SHIFT+F1Formats the source code (aka. Pretty Printer)
CTRL+SHIFT+F1Formats the marked source code or source code block (e.g. method)
CTRL+NCreates new development object
CTRL+SHIFT+XConvert marked editor content to upper case
CTRL+SHIFT+YConvert marked editor content to lower case
CTRL+UUnlock Editor

Navigation:

CTRL-LJump to line in editor
CTRL-OLaunch the quick outline
ALT+LEFT/RIGHTNavigate through the editor navigation history
CTRL+ ; / :Step quickly through the editor markers, like tasks, bookmarks, error markers, ATC findings etc.
F3Navigate to the definition of the selected element, e.g. variable, method, attribute etc.

Editor Tabs:

CTRL + EDisplays a list of all open editors
CTRL + F6Easily switch between the editor tabs (Like Tab for Windows)
CTRL + F7Easily switch between all eclipse views
CTRL + F8Easily switch between the perspectives
CTRL + MMaximize the active editor or viewer to full-screen mode
CTRL+3Easily open Eclipse views or trigger command via the Quick Access Input field
CTRL+PAGE UP/PAGE DOWNNavigate through the editor tabs forward and backward
ALT+PAGE UP/PAGE DOWNNavigate through the tabs of the class editor between global class, local class and test classes
CTRL + F4Close the active editor tab
CTRL+SHIFT+F4Close all editor tabs

Debugging:


CTRL+SHIFT+BSet a line break point in the ABAP editor



quinta-feira, 20 de abril de 2023

ABAP 740 - Collect usando FOR GROUP

TYPES: BEGIN OF tp_t,
         matnr TYPE matnr,
         tipo  type char1,
         cont  TYPE i,
       END OF tp_t.

types gkey type TABLE OF tp_t WITH DEFAULT KEY.

DATA t_teste TYPE TABLE OF tp_t.

APPEND VALUE #( matnr = 'A' cont = 1 ) TO t_teste.
APPEND VALUE #( matnr = 'A' cont = 1 ) TO t_teste.
APPEND VALUE #( matnr = 'B' tipo = 'X' cont = 1 ) TO t_teste.
APPEND VALUE #( matnr = 'B' cont = 2 ) TO t_teste.
APPEND VALUE #( matnr = 'B' cont = 3 ) TO t_teste.
APPEND VALUE #( matnr = 'D' cont = 2 ) TO t_teste.
APPEND VALUE #( matnr = 'C' cont = 1 ) TO t_teste.
APPEND VALUE #( matnr = 'C' cont = 1 ) TO t_teste.
APPEND VALUE #( matnr = 'C' tipo = 'W' cont = 1 ) TO t_teste.
APPEND VALUE #( matnr = 'C' tipo = 'W' cont = 1 ) TO t_teste.

data(lt_mat) =
  VALUE gkey(
    FOR GROUPS material OF wa IN t_teste
    GROUP BY ( matnr = wa-matnr
               tipo = wa-tipo )
               DESCENDING
               LET cont_1 = REDUCE tp_t( init line type tp_t
                                     for ls_c in group material
                                     NEXT line-matnr = ls_c-matnr
                                          LINE-TIPO = ls_c-tipo
                                          line-cont = line-cont + ls_c-cont ) in ( cont_1 ) ).


BREAK-POINT.

LOOP AT lt_mat INTO data(lsx).
  WRITE: / lsx-matnr, lsx-tipo, lsx-cont.
ENDLOOP.

terça-feira, 14 de fevereiro de 2023

Workflow - Erro formatação HTML na exibição SBWP

 - Para exibição de HTML no container da SBWP por mais que o HTML funcione 100% no ambiente tipo chrome, edge ou qualquer outra ferramenta para exibição no SAP especificamente na exibição de conteúdo as vezes aparece algumas tags fora de posição ou aparece a tag mesmo, etc..

Para resolver esse problema fiquei procurando até achar um cara que fala de uma nota da SAP q desconhecia até então falando justamente da do  HTML em editor sapscript.

2472157 - Work item description with HTML table in expression is not displayed correctly

Resumindo a nota a estrutura que deve ser usado para montar o HTML deve ser a TLINE_T que é a mesma estrutura do editor sapscript

Na primeira linha do sapscript no container do workflow deve ser colocado o texto MAIL_HTML_ONLY e depois a tabela que tem o HTML.

Ficaria dessa forma.











Transações WORKFLOW


SWU3 - Configuração de jobs automáticos

SWIA - Para eliminar processos de workflow parados na caixa de entrada 


Transação SMLG - Utilizei essa transação para configurar um erro que dava na conexão do servidor do workflow.

Ao testar a conexão dava um erro que não acha o grupo SPACE, nessa transação SMLG o grupo para o servidor estava em branco, eu preenchi com o SPACE e deu certo 


SWU_OBUFmanual buffer refreshSWPCcontinue WF after a system crash
SWI6show all WF instances, work item IDs by BOR/CL name & Object Key (optional)SWI5work item per work center, job, organizational unit, position, user
SWIAwork item administration (WI)SWI2_DIAGerror diagnosis
SWWLdelete work itemSWI2_DEADdeadline monitor
SWWL_TOPLEVELdelete a parent workflow with all of its child work itemsSWI2_DURAprocess duration
SWUDWF diagnosisSWI2_ADM1find orphaned work item
SWELSevent traceSM12lock, unlock the object
SWELdisplay event traceSARAarchiving

 

Workflow Development

SWDDWF builderSWNADMINnotification management
PFTCtemplate, task management (WS, TS)SM37view scheduled and processed jobs
PFTC_DISassigning possible agentSBWPWF inbox
PFACrule creation, editing, testingSWU0simulate the event linkage
SWO1business object builder (BOR)SWEQADMevent queue, preventing RFC-problem
SWUStest, execute WFSWB_CONDall start conditions
SWEINSTall terminating events linkageSWU9WF trace for the session
SWUI_VERIFYWF verificationSWI1selection report for work item
SOSTSAPconnect transmission requestSWPAcustomizing WF runtime system
SWNCONFIGnotification configurationPPOMorganization & staffing
SWEQBROWSERevent waiting in the event queuePPOMEorganizational management, structure & staff assignment, user mapping
SM52view tRFCSWI2_FREQopened task statistic

 

ABAP Development

SE24classesSE11data types, domains, tables
SE37function modules, functionsSE09list of change requests per SAP user
SE38programsSE03change requests management
ST22runtime error logs, dumpsSTMSchange requests transferring