Häufig gestellte Fragen

  • Syntaktischer Zucker

    * statt call function 'CONVERSION_EXIT_ALPHA_INPUT' " adding leading zeroes
    f_matnr = conv matnr( |{ l_matnr alpha = in }| ).

  • Q: How to join tables in DB02?
    A:

    select o.matnr, o.sernr, e.equnr, e.objnr
    from objk as o
    inner join equi as e on e.equnr = o.equnr
    inner join jest as j on j.objnr = e.objnr
    where o.matnr = 'XX035' and j.stat = 'I0102'
    and j.inact = ''
    and o.taser = 'SER03'
    and o.equnr not in ( select o0.equnr from objk as o0
    inner join equi as e0 on e0.equnr = o0.equnr
    inner join jest as j0 on j0.objnr = e0.objnr
    where
    j0.stat <> 'I0102'
    and o0.taser = 'SER03'
    and o0.matnr = 'XX035'
    and o0.equnr = o.equnr
    and j0.inact = '') group by o.matnr, o.sernr /* , e.equnr, e.objnr */
    order by o.sernr limit 100

  • Q: How to convert sy-datum type type to string DD.MM.YYYY?
    A: write sy-datum using edit mask ‘==PDATE’ to lv_datestring.
  • Q: How to convert CHAR type to RAW type?
    A:
    types: begin of c16,
    aaa(16) type c, "CHAR(16)
    end of c16.
    types: begin of r16,
    aaa type guid_16, "RAW(16)
    end of r16.
    data: it_chars type table of c16,
    it_raws type table of r16,
    c1(16) type c.
    c1 = '1234567890123456'.
    append c1 to it_chars.
    call method CL_RSZ_WWW_DB_INTERFACE=>CONVERT_CHAR_TO_RAW
    exporting
    I_T_IN = IT_chars
    importing
    E_T_OUT = it_raws
  • Q: What does mean asterisk in front of the name?
    A: EKPO and *EKPO are usually defined in TABLES statement, and both use the DDIC structure of EKPO. Classical usage is to distinguish between old and new value of the record.
    SELECT SINGLE * FROM *bkpf is equal to SELECT SINGLE * FROM bkpf into *bkpf
    the same as SELECT SINGLE * FROM bkpf is equal to SELECT SINGLE * FROM bkpf into bkpf
  • While declaring variables, always follow the naming conventions through out your code. Your variable names talks a lot about its usage.
    Make sure your variables are of the form:

    {Prefix1}{Prefix2}_{Name} where:

    Prefix1:
    L — Local
    I — Import
    E — Export
    G — Global
    T — Table Type

    Prefix2:
    V — Single Value
    S — Structure
    T — Table
    R — Type ref to Data
    O — Type ref to Object
    E — Type ref to Exception objects

    Name – name of the variable.
    e.g.:
    lt_sel — local table
    lo_rvs — local object
    and so on.

    Before changing the parameters (type or name), make sure that you run “Where used”, make a note and change them as well.
    While working on ABAP Classes and Interfaces, Never change a super class of a framework. It could potentially bring all applications down. Double check to make sure that the code you change is in your class only.

    Ctrl + D Duplicate any line.
    Ctrl + . & Ctrl + , Comment and Un-Comment selected lines.
    Ctrl+Shift+X Deletes the whole line.
    Ctrl+Shift+V Gives All Paste options.
    To assist in locating codes, can be a bookmark, using a combination: CTRL + ALT + (0 to 9).
    To go to bookmark created, use combination CTRL + (0 to 9).

    • Q: How to debug IDOCs IBOUND processing (most first FMs on receiver system (under ALEREMOTE non dialog user)?
      A: Simple and stupid solution is to put eternal loop in form FA5_DOCUMENT_SYNTAX_CHECK (program LEDI1FA5):

      data: x type flag.
      *if sy-uname eq 'SAPSD'.
      while x is initial.
      endwhile.
      "endif.

      Then the process will be available for debugging in the transaction SM50.
    • Please create lock objects on the header tables and make sure that you obtain a lock before changes and release the lock after changes.
    • Make sure that you transactions are atomic. Either commit your work after all changes are successful or Rollback in case of error. If you rollback, make sure that you have released the locks.
    • Q: How to pass dynamic varable into SELECT … WHERE IN clause?
      A:
      data: lv_pabprfs type string,
      qry type string.
      select single param from zparam into lv_pabprfs where paramid = 'PAPROFIL'.
      "lv_pabprfs = 'M033', 'M833', 'M843'
      qry = 'b~pabprf in (' && lv_pabprfs && ')'.

      select single baset into myvar from jitoco where outpo = '3' and (qry).

    • During save, please make sure that entries in all the text (_T_*) tables that relate to your modules are also saved. If no data exists, treat it as an error. (As across check, you can verify the same by executing the view and making sure that the data is returned correctly)
    • The Function should be RFC Enabled. Never raise an exception. Always return errors in the ET_RETURN (Type BAPIRET2) structure.
    • Never hardcode text strings. Make sure that you use a text element. But use it with text reference.
      E.g. If you have an error during validating the email, use it as «Email ID is required»(001) instead of using text-001. This will ensure that error messages are displayed regardless of user logon language.
    • At the end of the function, Always call «get details» and return the values as export/table values. This will serve the purpose of reflecting the data as-is in the DB back to the user and will save another round trip to retrieve it again.
    • Q: How to get variable value from another running program?
      A:
      "in case of needed programm isn't in the memory area, we can to call it via
      PERFORM change_control_record IN PROGRAM SAPMV50A.
      ld_mem = '(SAPMV50A)XLIPS[]'.
      ASSIGN (ld_mem) TO .
      IF sy-subrc = 0. "if ld_mem is assigned
      lt_xlips[] = .
      ENDIF.
    • Update audit fields created by, created date, created time only during create.
    • Please ensure that IV_UNAME (SY-UNAME) and IV_LANGUAGE (SY_LANGU) are mandatory for all modules. Extract the data for the language specified.
    • Q: Where are the packing handling units data stored during execution of transaction VL01/VL02/VL32N»? CVEKP table is always empty.
      A: The variable is (SAPLV51G)IVEKP[]
    • РІ: What are difference among 3 types of internal tables: standard, sorted and hashed?
      отв: Standard tables: the row numbering (index) is maintained internally. Both index and key accesses are possible. You should choose this table type when you mainly use the index to access the internal table.
      Sorted tables: the data records are automatically sorted in ascending order of the key fields. Here too, the index is maintained internally. Both index and key accesses are possible. You should choose this table type if you mainly access the internal table with the key or would like the table to be automatically sorted by key.
      Hashed tables: the data records are managed for fast key access using the hashing procedure. A unique key is required. With hashed tables only key accesses are possible. You should choose this table type if the internal table is very large and you want to access it by key only.

      DATA: lt_student1 TYPE STANDARD TABLE OF ty_students.
      DATA stab TYPE SORTED TABLE OF skb1 WITH UNIQUE KEY bukrs saknr.
      DATA htab TYPE HASHED TABLE OF skb1 WITH UNIQUE KEY bukrs saknr.

      You fill sorted tables using the INSERT statement. Entries are inserted according to the sort sequence defined through the table key. Any illegal entries are recognized as soon as you try to add them to the table. The response time for key access is logarithmically proportional to the number of table entries, since the system always uses a binary search. Sorted tables are particularly useful for partially sequential processing in a LOOP if you specify the beginning of the table key in the WHERE condition.

      You cannot access a hashed table using its index. The response time for key access remains constant, regardless of the number of table entries. Like database tables, hashed tables always have a unique key. Hashed tables are useful if you want to construct and use an internal table which resembles a database table or for processing large amounts of data. Accesses must use generic key operations (SORT, LOOP, etc.).

    • РІ: How to handle errors calling RFC-FM’s?
      отв: When you use CALL FUNCTION … DESTINATION … statement you should always add EXCEPTIONS section.

      data: begin of ls_msg,
      msgv1 type char50,
      msgv2 type char50,
      msgv3 type char50,
      msgv4 type char50,
      end of ls_msg.
      clear ls_msg.
      call function 'RFC_EXECUTE' destination 'DEST_RFC1'
      exceptions
      communication_failure = 1 message ls_msg
      system_failure = 2 message ls_msg.
      if sy-subrc ne 0.
      message i000(zzz)
      with ls_msg-msgv1
      ls_msg-msgv2
      ls_msg-msgv3
      ls_msg-msgv4.
      endif.

    • РІ: Wie kann i oi Email aus einem ALV-Rebord heraus verschigga?
      отв:

      data(lo_msg) = new cl_bcs_message( ).
      data lo_alv type ref to cl_salv_table,
      lv_xls type xstring.

      lv_xls = lo_alv->to_xml( xml_type = if_salv_bs_xml=>c_type_xlsx ).
      lo_msg->set_subject( 'Transaktion KREDITLI' ).
      loop at it_mail assigning filed-symbol ().
      lv_addr = -low.
      lo_msg->add_recipient( iv_address = lv_addr ).
      endloop.

      lo_msg->add_attachment( iv_filename = 'kreditli'
      iv_contents_bin = lv_xls ).
      lo_msg->set_update_task( abap_false ).
      lo_msg->send( ).

      lo_alv->display( ).