Thursday, April 16, 2020

Calling Workflow When We Creating Sales order in SAP ABAP.


Trigger Workflow When We Creating Sales order in SAP ABAP.




Trigger Workflow Creating Sales order in SAP ABAP.

*DATA :lt_container TYPE STANDARD TABLE OF swr_cont,
*      ls_container TYPE swr_cont.
*IF sy-tcode = 'VA02'.
*  SELECT SINGLE kvgr2 FROM vbak
*    INTO lv_kvgr2
*    WHERE vbeln = vbak-vbeln.
*  IF vbak-kvgr2 = lv_kvgr2.
*  ELSE.
**    PERFORM call_workflow.
*    flag_kvgr2 = 'X'.
*    ls_container-element = 'DOC_NO'.
*    ls_container-value = vbak-vbeln.
*    APPEND ls_container TO lt_container.
*    CLEAR : ls_container.
*
*    CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
*      EXPORTING
*        task                      = 'WS999001233'
*        language                  = sy-langu
*        do_commit                 = 'X'
*        user                      = sy-uname
**       START_ASYNCHRONOUS        = ' '
**       DESIRED_START_DATE        =
**       DESIRED_START_TIME        =
**       DESIRED_START_ZONLO       = SY-ZONLO
**       IFS_XML_CONTAINER         =
**     IMPORTING
**       RETURN_CODE               =
**       WORKITEM_ID               =
**       NEW_STATUS                =
*      TABLES
*        input_container           = lt_container
**       MESSAGE_LINES             =
**       MESSAGE_STRUCT            =
**       AGENTS                    =
*              .
*    IF sy-subrc = 0.
*      EXPORT flag_kvgr2 FROM flag_kvgr2 TO MEMORY ID 'SY-UNAME'.
*    ENDIF.
*  ENDIF.
*ENDIF.

Validation for Purchase requisition date before saving purchase requisition date.

                       
  • Validation for Purchase requisition date before saving purchase requisition date.

  • Purchase requisition date validation.

  • User exit MEREQ001.


Use this EXIT_SAPLMEREQ_005 function module for displaying error messages at the time of saving of  Purchase requisition.


DATA Fcode TYPE  Sy-UCOMM.
if im_data_new-badat < sy-datum.
    MESSAGE 'Purchase requisition Date not is less than the System Date' TYPE 'E'.
   endif.
   if im_data_new-FRGDT < sy-datum.
     MESSAGE 'PR Release Date not is less than the System Date' TYPE 'E.
   endif.


Thursday, March 19, 2020

READ_TEXT Function Module call in program In SAP ABAP.


READ_TEXT Function Module Use in SAP.


READ_TEXT Function Module.

DATA:lv_output_text TYPE char50.

PERFORM f_read_text USING 'ABCD'            " Text ID
                          'E'               " Text Language
                          '12345678'        " Text Name
                          'VBBK'            " Text Object
                 CHANGING lv_output_text.   " Return Text

*Display the standard text.
WRITE lv_output_text.

*----------------------------------------------------------------------*
FORM f_read_text USING pi_textid      TYPE thead-tdid
                       pi_language    TYPE thead-tdspras
                       pi_name        TYPE thead-tdname
                       pi_object      TYPE thead-tdobject
              CHANGING pc_output_text TYPE char50.
*----------------------------------------------------------------------*
* Data Declarations.
* Internal Tables.
  DATA:
    lt_lines TYPE STANDARD TABLE OF tline.

* Field Symbols.
  FIELD-SYMBOLS:
    <fs_lines> TYPE tline.

* Clearing field to be on the safer side.
  CLEAR pc_output_text.

  CALL FUNCTION 'READ_TEXT'
    EXPORTING
      id                             = pi_textid
      language                  = pi_language
      name                        = pi_name
      object                  = pi_object
    TABLES
      lines                         = lt_lines
    EXCEPTIONS
      id                             = 1
      language                  = 2
      name                        = 3
      not_found            = 4
      object                   = 5
      reference_check         = 6
      wrong_access_to_archive = 7
      OTHERS                  = 8.

  IF sy-subrc EQ 0.

*  Fetch the text from the FM table.
    READ TABLE lt_lines
    ASSIGNING <fs_lines>
    INDEX 1.

    IF sy-subrc EQ 0.

*    Standard text Details.
      pc_output_text = <fs_lines>-tdline.

    ENDIF.

  ENDIF.

ENDFORM.