Häufig gestellte Fragen

  • Syntaktischer Zucker
      data(lr_nach) = value rseloption( option = 'EQ' sign = 'I' ( low = 'Z2N' )
                                                                 ( low = 'NEU' ) ).   
    * statt append ls_goodsmvt_item to lt_goodsmvt_item
      append value #( material   = matnr
                      plant      = from_plant
                      stge_loc   = from_stloc
                      move_plant = to_plant
                      move_stloc = to_stloc
                      move_type = '309'                          " Bewegungsart.
                      entry_qnt = menge
                      entry_uom = <fs>-meins ) to lt_goodsmvt_item.
     
    * statt  call function 'CONVERSION_EXIT_ALPHA_INPUT' " adding leading zeroes
    f_matnr = conv matnr( |{ l_matnr alpha = in }| ).
     
    result = VALUE #( FOR row IN input ( row-text ) ).
    " LOOP AT input INTO DATA(row).
    "  INSERT row-text INTO TABLE result.
    " ENDLOOP.
     
    DATA(line) = value_pairs[ name = 'A' ].
    " READ TABLE value_pairs INTO DATA(line) WITH KEY name = 'A'.
     
    DATA(exists) = xsdbool( line_exists( value_pairs[ name = 'A' ] ) ).
    IF line_exists( value_pairs[ name = 'A' ] ).
    " READ TABLE value_pairs TRANSPORTING NO FIELDS WITH KEY name = 'A'.
    " DATA(exists) = xsdbool( sy-subrc = 0 ).
  • 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 <mem>.
        IF sy-subrc = 0. "if ld_mem is assigned
          lt_xlips[] = <mem>.
        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-&gt;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( ).
       
      *                                         ///*
      *                                   ///////////////////
      *                             ,///////////////////////
      *                            (/////////////////////
      *                            (////////////////////////
      *                         (///////////////////////////*
      *                       /////////////////////////////
      *                              (//////////////////////
      *                                ///////////////////(
      *                                ///////////////(              ////*/
      *                               //////////////////       //////////////
      *                              ////////////////////////////////////////
      *                            */////////////////////////////////////////
      *                           //////////////////////////////////////(*
      *                          /////////////////////////////////////.
      *                        ,/////////////////////////////////(/
      *                      *//////////////////////////////(#
      *                    (//////////////////////////////
      *                  (//////////////////////////////////
      *                ///////////////////////////////////////
      *              ////////////////////(   #//////////////////
      *            ////////////////////        ((/////////////////*,,.
      *          *//////////////////(            /(//////////////////////*
      *            ///////////////.                 (///////////////////
      *              ,/////////////                   (///////////////
      *                  (//////////                    //////////
      *                       .(////                      (///

    Discussion

    Ruslan
    06.11.2020
    Kурсы BC400, BC410. Следующие общеиспользуемые вещи: Отчет ALV, через FM REUSE_ALV_GRID Печатная форма PDF: заголовок, тч, подвал Печатная форма smartforms Выгрузка в Excel через ZWWW Загрузка из плоского файла Создание Z-таблицы в словаре, ракурс к ней в SM30, прямой апдейт Несложный FM Отчет на ALV с применением ООП Экраны (нарисовать), данные в них менять Средство поиска для Z-таблицы Программа со всеми этими компонентами
    Ruslan
    06.11.2020
    Type Length Standard length Value Area Initial Value Description
    b 1 Byte   0 to 255 0 1 byte integer (internal)
    c 1 to 65,535 characters 1 character Any alphanumeric character " " for every position Text field
    d 8 characters   8 user-defined alphanumeric characters; Only values in the format YYYYMMDD that are permitted as date entries according to the calendar rules are valid: YYYY (year): 0001 to 9999, MM(month): 01 to 12, DD (day): 01 to 31 "00000000" Date field
    f 8 bytes   Floating point numbers are displayed internally with 16 decimal places according to the IEEE-754 standard (double precision). Valid values are -1,7976931348623157EE+308 to -2,2250738585072014EE-308 for the negative area, the value zero, and +2,2250738585072014EE-308 to +1,7976931348623157EE+308 for the positive area. Both validity areas are extended in the direction of zero through denormalized numbers after IEEE-754. 0 Floating point number
    i 4 bytes   -2.147.483.648 to +2.147.483.647 0 4 byte integer
    n 1 to 65,535 characters 1 character Any alphanumeric characters, however, valid values are only the digits 0 to 9 "0" for every position. Numeric text
    p 1 to 16 bytes 8 bytes The valid length for packed numbers is between 1 and 16 bytes; two decimal places are packed into one byte, whereby the last byte only contains one place and the plus/minus sign; after the decimal separator, up to 14 decimal places are permitted. Depending on the field length len and the number of decimal places dec, the following applies for the value area: (-10^(2len -1) +1) / (10^(+dec)) to (+10^(2len -1) -1) /(10^(+dec)) in steps of 10^(-dec). Values in between this range are rounded off. 0 Packed number
    string variable   as for type c empty string of length 0 Text string
    s 2 bytes   -32.768 to +32.767 0 2 byte integer (internal)
    t 6 characters   6 user-defined alphanumeric characters; the only valid values are numbers that are interpreted as a time specification in the 24-hour clock format HHMMSS. SAP recommmends to exclusively use 00 to 23 hours for HH (hours) and 00 to 59 for MM (minutes) and 00 to 59 for SS (seconds). "000000" Time field
    x 1 to 65,535 bytes 1 byte hexadecimal characters 0-9, A-F hexadecimal 0 Byte field
    xstring variable   as for type x empty string of length 0. Byte string

    These types are predefined in every ABAP program.

    • All predefined ABAP types in this table are elementary.
    • Apart from the types b and s, the predefined ABAP types can also be used to define your own data types and data objects and for typing. The types b and s cannot be specified directly in ABAP statements. Self-defined data types and data objects in ABAP programs are of the data type b and s if they are defined with reference to data elements to the ABAP Dictionary which are of the external data types INT1 or INT2.
    • The program-globally predefined data type cursor is currently synonymous with the predefined ABAP type i. This is required for the declaration of a cursor variable for database cursor handling.
    • All predefined ABAP types for which a length interval is specified in second column in the table are generic, which means that the length is not part of the type description. For the type p, the fractional portion is indefinite as well as the length.
    • The entries in the standard length column specify the length that is used for the corresponding generic data type when declaring data objects, if no explicit length is specified in the relevant statement.
    • In Unicode systems, the length must either be specified in characters and bytes. In non-Unicode systems, the length of a character is one byte, but in Unicode systems the length of a character depends on which Unicode character representation is used.

    Notes

    • The system class CL_ABAP_EXCEPTIONAL_VALUES contains methods that return the minimum and maximum value for a data object (as of release 6.10).
    • As the decimal places of a floating point number of type f are represented internally as dual fractions, there is not an exact equivalent for every number that can be represented in the decimal system. This can lead to rounding errors in assignments and intermediate results of calculations. These errors can be avoided by using a two-step rounding procedure.
    • For data objects of data type p, the program attribute fixed point arithmetic must be set so that the decimal separator is taken into account. Otherwise, the content is handled as if there is no decimal separator, in all operations except for displaying a list.
    • Data objects of the data type t that contain numbers outside the value range 00 to 23 for hours and 00 to 59 for minutes and seconds can be converted to numeric values, but are invalid when using time stamps.
    Ruslan
    06.11.2020
    read table lt_pkYY with key pknum = wa_pkhd-pknum into wa_pkYY.
    
      select vbeln verur from likp
                   into table lt_wahl2
                   for all entries in lt_wahl
                   where vbeln eq lt_wahl-vbeln.
    
    select paramval from param_const into corresponding fields of table lt_params where paramid  = 'LIEFERUNGSNUMMER'.
     if sy-subrc eq 0.
      field-symbols:  type lipov.
      loop at ct_worktab assigning .
        read table lt_params
        with key paramval = -lfart transporting no fields.
       if sy-subrc eq 0.
    "all the selected deliveries are in param_const"
    
    Ruslan
    06.11.2020
    Shift leading/trailing symbols:
    c1 = 00000000000000000000000000000101334 (35 chars)
    c2 (20 chars).
    
    move c1+19(16) to c2.
    result: c2 is eq to '00000000000000101334'.
    Trailing - c1(16)+19 etc.
    
    Ruslan
    06.11.2020
    try. ... call function '...' ... endif. catch cx_root into data(lo_ex). " Fehler ignorieren endtry.

    Schreibe einen Kommentar



    All fields are required. Your email address will not be published.