Edit variants

function y_jc_inb2out.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  TABLES
*"      JITCALLS TYPE  JITO_PRODN_TT
*"----------------------------------------------------------------------
types: begin of ts_data,
  spec_matnr type matnr,
  end of ts_data,
 
 tt_data type table of ts_data.
   data: lt_params type table of rsparams,
        ls_varid type varid.
 
  field-symbols:<wa_params> like line of lt_params.
                ", <wa_data>  like line of pt_data.
 
  define add_params.
    append initial line to lt_params assigning <wa_params>.
    <wa_params>-selname = &1.
    <wa_params>-kind = &2.
    <wa_params>-sign = &3.
    <wa_params>-option = &4.
    <wa_params>-low = &5.
  end-of-definition.
 
  ls_varid-report  = 'RJITMON001'.
  ls_varid-variant = '/Y_SCMORDERS'.
  ls_varid-ename   = 'YSD'.
  ls_varid-edat    = sy-datum.
  ls_varid-etime   = sy-uzeit.
 
  add_params: 'PRODN_PT' 'S' 'I' 'EQ' '6233'.
 
 CALL FUNCTION 'RS_CHANGE_CREATED_VARIANT'
    EXPORTING
      curr_report               = ls_varid-report
      curr_variant              = ls_varid-variant
      vari_desc                 = ls_varid
    TABLES
      vari_contents             = lt_params
    EXCEPTIONS
      illegal_report_or_variant = 1
      illegal_variantname       = 2
      not_authorized            = 3
      not_executed              = 4
      report_not_existent       = 5
      report_not_supplied       = 6
      variant_doesnt_exist      = 7
      variant_locked            = 8
      selections_no_match       = 9
      OTHERS                    = 10.
  IF sy-subrc <> 0.
*    MESSAGE s020(Y_SAP) WITH p_var DISPLAY LIKE 'E'.
*  ELSE.
*    MESSAGE s021(Z_SAP) WITH p_var.
  ENDIF.
endfunction.

Own customer exit for JITL (JITPP)

Broadcast from jit.sap.sd/jitl:

Defining the production info describes principles of using the table JITPP («JIT : Production Information») – repetitive manufacturing (A), stock transfer (B) and customer exit (Z). Table field is JITPP-BAFLU.

The transaction for controlling this behaviour is JITL:

The last one (customer exit) is very typical customer-function call, which is calls from functional module JIT03_DO_BACKFLUSH (CALL CUSTOMER-FUNCTION ‹009›), so function EXIT_SAPLJIT03_009 transmits into include ZXJIT0U19 next structures:

JITDIABACKF_IT STRUCTURE  JITDIABACKF  "Aggregate Information on Call Components
JITBACKFTMP_CT STRUCTURE  JITBACKFTMP  "Backflush Data Call Components
JITIT_IT       STRUCTURE  JITIT        "Table of Components Groups Involved

*Modifikation der Rückmeldedaten

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( ).
       
      *                                         ///*
      *                                   ///////////////////
      *                             ,///////////////////////
      *                            (/////////////////////
      *                            (////////////////////////
      *                         (///////////////////////////*
      *                       /////////////////////////////
      *                              (//////////////////////
      *                                ///////////////////(
      *                                ///////////////(              ////*/
      *                               //////////////////       //////////////
      *                              ////////////////////////////////////////
      *                            */////////////////////////////////////////
      *                           //////////////////////////////////////(*
      *                          /////////////////////////////////////.
      *                        ,/////////////////////////////////(/
      *                      *//////////////////////////////(#
      *                    (//////////////////////////////
      *                  (//////////////////////////////////
      *                ///////////////////////////////////////
      *              ////////////////////(   #//////////////////
      *            ////////////////////        ((/////////////////*,,.
      *          *//////////////////(            /(//////////////////////*
      *            ///////////////.                 (///////////////////
      *              ,/////////////                   (///////////////
      *                  (//////////                    //////////
      *                       .(////                      (///

    Набор полезных программ

    Получить внешние вызовы ФМ, транзакций и многого другого внутри программы можно с помощью программы — RSINCL00.

    Транзакция ABAPDOCU — ABAP документация и примеры.

    Транзакция BIBS — примеры пользовательского интерфейса для ABAP программ.

    Транзакция DWDM — демо примеры с использованием Enjoy контролов.

    Программа ADBC_DEMO — демо программа ADBC API (для подключения к внешним базам данных).

    Транзакция SE83 — библиотека примеров с ALV и прочими контролами.

    Программа BALVBT01 — демонстрация множественного использования ALV.

    Программа SHOWICON — список всех иконок.

    Программа SHOWCOLO — все цвета используемые во WRITE или ALV.

    Программа SHOWLINE — всевозможные линии во write отчётах.

    Программа SHOWSYMB — символы.

    Программа AFX_CODE_SCANNER (или RPR_ABAP_SOURCE_SCAN) — поиск в исходных кодах.

    Программа RSBDCOS0 — выполнение системных команд на сервере.

    Программа REPTRAN — массовая выгрузка исходников.

    © abap-blog.ru