Category Archive ABAP code

Hide a subform according to context node value

To hide a subform using javascript according a context node value in Adobe form :


// data.MAIN.SUBFORM_TO_HIDE::ready:form - (JavaScript, client)
var fieldToCheck= xfa.resolveNode("$record.MAIN.FIELD_VALUE");
if(fieldToCheck.value == null || fieldToCheck.value == "") {
    this.presence = "hidden";
}

Adobe form, count number of elements in a subform with JS

The goal here is to define of there are data into the table, if not, we hide the subform. That means, we hide the whole table (border and header line).
There are several ways to proceed, this is one :

Table from context is binded like :

  • TABLE_TEXT_HEADER_PO binded with $.TABLE_HEADER
  • LINE_TEXT_HEADER_PO binded with $.DATA[*] (repeat subform for each data item is ticked)
  • HEADER_PO_TEXT binded with $.TEXT_CONTENT
Read More

FM to generate Planned Independent Requirement (PIR)

Planned Independent Requirement (PIR) are managed through transaction MD6x.
(Do not confuse with Purchase infos records 😉)

FM to manage PIR with ABAP are :

  • BAPI_REQUIREMENTS_CREATE
  • BAPI_REQUIREMENTS_CHANGE
Read More

Convert time unit into seconds

The goal is to convert whatever time unit declared on system into hour in ABAP.
One way to proceed is to check table T006.
Filter dimension (DIMID) on ‘TIME’ to get only time unit and retrieve fields numerator (ZAEHL), denominator (NENNR) and exponent (EXP10) to get time in seconds.

Read More

Get production orders status

According to your needs, you can use FM AIP9_STATUS_READ or FM STATUS_READ.

FM AIP9_STATUS_READ


  DATA : lv_objnr         TYPE j_objnr,
         lv_system_status TYPE j_stext, " (CHAR40)
         lv_user_status   TYPE j_stext. " (CHAR40)

  CONCATENATE 'OR' gv_aufnr INTO lv_objnr.

  CALL FUNCTION 'AIP9_STATUS_READ'
    EXPORTING
      i_objnr = lv_objnr
      i_spras = sy-langu
    IMPORTING
      e_sysst = lv_system_status
      e_anwst = lv_user_status.

This will return in each wa list of system and user external status (in requested language) separated by space.

FM STATUS_READ :


  DATA : lv_objnr         TYPE j_objnr,
         lt_status        TYPE STANDARD TABLE OF jstat,
         lv_status_schema TYPE j_stsma.

  CONCATENATE 'OR' gv_aufnr INTO lv_objnr.

  CALL FUNCTION 'STATUS_READ'
    EXPORTING
      objnr            = lv_objnr
      only_active      = 'X'
    IMPORTING
      stsma            = lv_status_schema
    TABLES
      status           = lt_status
    EXCEPTIONS
      object_not_found = 1
      OTHERS           = 2.

This will return internal status id in LT_STATUS.

Read More

Create XSTRING type field into a structure

You can use the data element : UMC_Y_CONTENT.

Type RAWSRTING which has the same behavior as XSTRING.

How to find exit enhancement/extension name from FM name

Check table : MODSAP.

For example, to get enhancement (extention in french) of EXIT_SAPLV56K_002 ,
enter with Enhancement (field MEMBER) =  EXIT_SAPLV56K_002, you will get in field NAME the enhancement name : V56K0001.

Convert internal table to CSV

You can use FM SAP_CONVERT_TO_CSV_FORMAT :

Read More

Display right HTML docker container in selection screen

Code example to display a HTML docker container on the right of a selection screen (to display help for instance).

Read More

ABAP operator MIN & MAX

Use statements NMIN and NMAX.
⚠️ Maximum 9 values can be passed : val1, val2… val9.


    DATA : lv_nb1 VALUE 25,
           lv_nb2 VALUE 50,
           lv_nb3 VALUE 100.

    DATA(lv_nb_max) = nmax( val1 = lv_nb1
                            val2 = lv_nb2
                            val2 = lv_nb3 ).

    DATA(lv_nb_min) = nmin( val1 = lv_nb1
                            val2 = lv_nb2
                            val2 = lv_nb3 ).

    " ==> LV_MAX = 100
    " ==> LV_MIN = 25

Search tag: maximum minimum