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