Category Archive ABAP code

Byfjourneau

Get fullname from User-id

Use code below :


" ADRP-NAME_FIRST : First name
" ADRP-NAME_LAST  : Last name
" ADRP-NAME_TEXT  : Full name

DATA : lv_usrid     TYPE XUBNAME,
       lv_name_text TYPE ADRP-NAME_TEXT.

" [...]

SELECT SINGLE adrp~name_text INTO lv_name_text
  FROM usr21 JOIN adrp ON usr21~persnumber = adrp~persnumber
                      AND adrp~date_from   = '00010101'
                      AND adrp~nation      = ''
  WHERE usr21~bname = lv_usrid.

Byfjourneau

Insert break line in ABAP string

To insert a BR in a string char, use the following constant :


cl_abap_char_utilities=>cr_lf

Search tag : CrLf, retour chariot, ligne, newline, new, carriage return

Byfjourneau

Convert standard texts to string

The method below enables to convert standard texts to string (with carriage returns). It can be useful when standard texts need to be changed or completed before being printed on Adobe forms.
(Otherwise, it is recommanded to use the standard text objet for Adobe forms).

Read More
Byfjourneau

Catch HTML events with ABAP

Check program SAPHTML_EVENTS_DEMO.

Byfjourneau

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";
}

Byfjourneau

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
Byfjourneau

FM to generate PIR

Planned Independent Requirement (PIR) are managed through transaction MD6x.

FM to manage PIR with ABAP are :

  • BAPI_REQUIREMENTS_CREATE
  • BAPI_REQUIREMENTS_CHANGE
Read More
Byfjourneau

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
Byfjourneau

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.

  CONCATENATE 'OR' gv_aufnr INTO lv_objnr.

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

This will return internal status id.

Read More
Byfjourneau

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.