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.