Thursday, January 12, 2012

Workflow: "Schedule Background Job for Condition Evaluation"

In workflow customizing setting, we can set up a background job to monitor all the condition that you had built in the workflow. The background job should be run every 30 mins.
But, sometimes you can't waste your time to wait the background job to execute, and you need to execute it manually. You can do this by execute the report "RSWWCOND" in SE38, and the result will be same.

Tuesday, December 27, 2011

Check payroll result in your system

Today, I need to find out whether is there any existing payroll result in our demo system. A very useful transaction code is "PC_PAYRESULT".








Fill in the employee number that you want to check whether got payroll result exist for the employee, and then hit Enter. You also can enter a range for the employee number.

To read the payroll result from my program, I am using function module "CU_READ_RGDIR" to get the RGDIR, then use function module "CD_READ_LAST" to get the SEQNR. Then, I use function module "PYXX_GET_RELID_FROM_PERNR" to get the RELID, and then use function module "PYXX_READ_PAYROLL_RESULT" to get the payroll result.

 The changing parameter of the function module "PYXX_READ_PAYROLL_RESULT" -> "PAYROLL_RESULT", will be type "pay99_result" for international payroll result. If the payroll result for GB, then we can use type "paygb_result".

The payroll result might consist of a lot technical wage type in the RT table, to understand what is those wage type, you can refer to the view "V_T512T" from SM30.

Thursday, October 6, 2011

Agent assignment in Workflow

In development system, I had created a task, and also configure the agent assignment correctly:
A problem I always had was, when I transport this workflow into Quality system, the agent assignment setting is gone, and I got to configure the agent assignment manually in Quality and Production system:
This is very troublesome, and we need to check every task in both systems after the transport done. But, I found a very good post from SAPTechnical. I would like to keep the guideline in here as well, in case the link is gone:)

1. Go to Tcode "RE_RHMOVE30", and fill in the details as following:
    Object Type should be "TS" for Standard Task, and Object ID should be the standard task ID that contains the Agent Assignment that you wish to transport.
2. Execute it. At the next screen, SELECT all the object that you wish to transport, and then click "Transport/Delete":
3. Then, the system will prompt you for customizing request, you should select/create appropriate customizing request and then choose "Continue".
4. After this, the Agent Assignment of the standard task had been add into a customizing request. You can transport this request to Quality system and then Production system.
5. With this transport get into the next system, you no need to manually configure the Agent assignment for each of the standard task in Quality/Production system.

Whenever we create an Agent Assignment in Development system, we should also add this Agent Assignment setting to a transport at the same time, with the above steps.

User's email address

The user's email address that I mean here is the email address that maintained in transaction code SU01:


In order to get this email address in program, you can use BAPI "BAPI_USER_GET_DETAIL", this will be very handy.


But, which table keep this email address? The answer is ADR6, but by looking into the content of this table, it did not has a field for user id. The key field for this table is ADDRNUMBER and PERSNUMBER, and how can we can this number?


Go into table USR21, find the user's ADDRNUMBER and PERSNUMBER by searching with user id in keyfield BNAME. Then, get the email address from table ADR6 with these two fields.

Thursday, June 9, 2011

SAP Code Page for UTF-8 and UTF-16 Unicode encoding

SAP has different number to indicate character encoding for UTF-8 and UTF-16. SAP call it code page number. UTF-8 is using number 4110 and UTF-16 is using number 4102.
*Note: 4103, 4104 and 4105 also are Unicode code page, you can see it in table "TCP00".

For example:
If we want to export an Excel file by using "GUI_DOWNLOAD" with encoding "UTF-16", then at the Exporting parameter "CODEPAGE", pass the value "4102" then the file will be export with UTF-16 encoding.

We can find all the code page that supported by SAP in table "TCP00".

Wednesday, June 8, 2011

How to get the Year, Month and Day different between two dates?

Sometime we need to know the different between two dates, for example, Employment Period.
Example, James joined the company on 15.01.2001 and resigned on 28.03.2011, how long had James worked in the company? The employment period for James should be 10 Years, 2 Months and 14 Days.
How we going to get this? Function module "HR_GET_TIME_BETWEEN_DATES" will do this for you.

Figure 1:

Thursday, June 2, 2011

ABAP Report: Formatted Excel Output File

The source is from "http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/13092".
The XML part looks complicated initially, but after get familiar with the TAGs, I able to write XML easily. I love this:-)

Sample ABAP Program:
REPORT  zedi_excel_xml.

TYPESBEGIN OF ty_emp,
        pernr TYPE persno,
        ename TYPE emnam,
       END   OF ty_emp.

DATA: itab TYPE STANDARD TABLE OF ty_emp,
      la_tab LIKE LINE OF itab,
      xmlstr TYPE string.

START-OF-SELECTION.

*---------
* Test table
*---------
  SELECT pernr ename FROM pa0001 INTO TABLE itab UP TO 30 ROWS.

*---------
* Get the XML data excel
*---------
  CALL TRANSFORMATION zedi_excel_xml
    SOURCE table = itab
    RESULT XML xmlstr.

*---------
* Download the file
*---------

* Fill the table
  DATA: xml_table TYPE STANDARD TABLE OF string.

  APPEND xmlstr TO xml_table.

  DATA: window_title TYPE string,
        fullpath TYPE string,
        path TYPE string,
        user_action TYPE i,
        default_extension TYPE string,
        default_file_name TYPE string,
        file_filter TYPE  string,
        filename TYPE string,
        initialpath TYPE string.

* File selection
  MOVE '.XLS' TO default_extension.
  MOVE 'XLS files (*.XLS)|*.XLS' TO file_filter.

  CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
      default_extension = default_extension
      default_file_name = default_file_name
      file_filter       = file_filter
      initial_directory = initialpath
    CHANGING
      filename          = filename
      path              = path
      fullpath          = fullpath
      user_action       = user_action
    EXCEPTIONS
      cntl_error        = 1
      error_no_gui      = 2
      OTHERS            = 3.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

* download file
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename                = fullpath
      filetype                = 'ASC'
    TABLES
      data_tab                = xml_table
    EXCEPTIONS
      file_write_error        = 1
      no_batch                = 2
      gui_refuse_filetransfer = 3
      invalid_type            = 4
      OTHERS                  = 5.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

Sample XML Transformation