SAP Most Handy FM For Abaper

SAP Most Handy FM For Abaper

well hello again fellas,

there are times when you need to modify tiny little details of your program in order to make it looking good.

for example,

1 . Coversion Exit output / input

as for the “Vendor” field, the data could be leading with ‘0’, if this bothers you or your functionality colleagues. this fm might come in handy.

see that Vendor Field, the data is leading with ‘0’, to easily convert this you need ‘CONVERSION_EXIT_ALPHA_OUTPUT’ .

‘CONVERSION_EXIT_ALPHA_OUTPUT’ is use when you need to delete leading 0 in vendor field, while

‘CONVERSION_EXIT_ALPHA_INPUT’ is use when you want to add leading 0 automatically.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
          EXPORTING
            INPUT         = ls_ekko-lifnr
         IMPORTING
           OUTPUT        = LS_INPUT-Vendor
                  .
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT         = ls_ekko-lifnr
         IMPORTING
           OUTPUT        = LS_INPUT-Vendor
                  .

2. Conversion Amount SAP to Display or vice versa

there are times when you need to extract data from the table, but when you display them, the amount is incorrect, this is because sap has currency fields for each amount field, in order to display it correctly you need to convert it using the currency.

the easiest way to do it is just using FM CURRENCY_AMOUNT_SAP_TO_DISPLAY / CURRENCY_AMOUNT_DISPLAY_TO_SAP

        CALL FUNCTION 'CURRENCY_AMOUNT_SAP_TO_DISPLAY'
          EXPORTING
            CURRENCY              =  ls_ekko-waers
            AMOUNT_INTERNAL       = lv_amount_int
        IMPORTING
          AMOUNT_DISPLAY        = lv_amount_ext
        EXCEPTIONS
          INTERNAL_ERROR        = 1
          OTHERS                = 2
                 .
        CALL FUNCTION 'CURRENCY_AMOUNT_DISPLAY_TO_SAP'
          EXPORTING
            CURRENCY              =  ls_ekko-waers
            AMOUNT_INTERNAL       = lv_amount_int
        IMPORTING
          AMOUNT_DISPLAY        = lv_amount_ext
        EXCEPTIONS
          INTERNAL_ERROR        = 1
          OTHERS                = 2
                 .

or Simply just use

Write lv_a into lv_b Currency lv_C.

3. POP UP FM YES/NO Answer

there are times when you need an Yes/No Question from Users the answer depending on the flow of the programs,

the easiest way to do this is using fm POPUP_TO_CONFIRM

DATA : lv_ques TYPE string,
       lv_ans  TYPE char4.
       lv_ques = 'Data yang sudah di-input tidak dapat diubah. Mohon pastikan angka yang anda input sudah tepat! Save?'.
      CALL FUNCTION 'POPUP_TO_CONFIRM'
        EXPORTING
*         TITLEBAR                    = ' '
*         DIAGNOSE_OBJECT             = ' '
          TEXT_QUESTION               = lv_ques
         TEXT_BUTTON_1               = 'Save'(001)
         ICON_BUTTON_1               = 'ICON_SYSTEM_SAVE'
         TEXT_BUTTON_2               = 'Cancel'(002)
         ICON_BUTTON_2               = 'ICON_INCOMPLETE'
*         DEFAULT_BUTTON              = '1'
         DISPLAY_CANCEL_BUTTON       = ' '
*         USERDEFINED_F1_HELP         = ' '
*         START_COLUMN                = 25
*         START_ROW                   = 6
*         POPUP_TYPE                  =
*         IV_QUICKINFO_BUTTON_1       = ' '
*         IV_QUICKINFO_BUTTON_2       = ' '
       IMPORTING
         ANSWER                      = lv_ans
*       TABLES
*         PARAMETER                   =
       EXCEPTIONS
         TEXT_NOT_FOUND              = 1
         OTHERS                      = 2
                .

4. Message

creating a message could be a pain in the ass, here’s the easiest way to do it, make a define statemet and just call it later.

Data :        
       gl_subrc           TYPE sy-subrc,
       gl_tabix           TYPE sy-tabix,
       gl_dummy           TYPE char72.
DEFINE mmpur_message.
  set extended check off.
  gl_tabix = sy-tabix.
  gl_subrc = sy-subrc.
  message id &2 type &1 number &3 with &4 &5 &6 &7 into gl_dummy. "#EC MG_PAR_CNT
  call method cl_message_mm=>create
    exporting
      im_msgid = &2
      im_msgty = &1
      im_msgno = &3
      im_msgv1 = sy-msgv1
      im_msgv2 = sy-msgv2
      im_msgv3 = sy-msgv3
      im_msgv4 = sy-msgv4
    exceptions
      failure  = 01
      dialog   = 02.
  if sy-subrc = 1 or sy-subrc = 2.
    message id sy-msgid type sy-msgty number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  endif.
  sy-subrc = gl_subrc.
  sy-tabix = gl_tabix.
  set extended check on.
END-OF-DEFINITION.
"Call below Statement
       mmpur_message 'E'
                      'ZM'
                      '019'
                      'Please input Capaian TKDN. '
                      space
                      space
                      space.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *