Saturday, 14 April 2012

Hiding fields in an Infotype

It is sometimes required to customize the screen fields in the HR Infotypes. This can be done using
the view V_T588M.

hide_fields0


1. If we see in PA30, the standard screen for 0023 (Other/Previous Employers) is:
hide_fields1
2. Let us hide the field “Work Contract” & “Job” from the standard Infotype screen.
hide_fields2
Go to SM30 & enter view name as “V_T588M”. Click on “Maintain”.
hide_fields3
3. Enter the module pool program & click Ok. In our case it is MP002300.
hide_fields4
4. Now click on ‘New Entries’ button.
hide_fields5
5. Now enter the “Module Pool” (mandatory) “Standard screen” (mandatory).Press “Enter”.
hide_fields6
6. After we press “Enter”, all the screen fields of the Infotype are shown along with their attributes.
7. Now, we can change the attributes according to our requirements by selecting the desired radio button. After that press Save.
hide_fields7
8. Then Go to PA30 and check the changes done to the standard Infotype (here Infotype 0023). The fields we chose to hide gets hidden.
hide_fields8

Thursday, 12 April 2012

Get Employees List

HR ABAP - Get Employees List Working Under An Organization Unit.


report ztests.

parameters:p_objid type orgeh .

data: pernr_table type HRPERNR occurs 0 with header line .

CALL FUNCTION 'HRCM_ORGSTRC_EMPLOYEE_LIST_GET'
EXPORTING
  plvar = '01'
  root_otype = 'O'
  root_objid = p_objid
  begda = '18000101'
  endda = '99991231'
TABLES
  pernr_table = pernr_table
EXCEPTIONS
  NO_ORGSTRUC_FOUND = 1
  NO_EMPLOYEES_FOUND = 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.

loop at pernr_table.
  write:/ pernr_table-PERNR.
endloop.

Tuesday, 10 April 2012

OOPS-5

REPORT  ZO_CLASS5.

*----------------------------------------------------------------------*
*       CLASS CLASS1 DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS CLASS1 DEFINITION.

  PUBLIC SECTION.
    DATA: INSTDATA(25) TYPE C VALUE 'Instance Variable'.
    METHODS: INSTMET.

    CLASS-DATA: STATDATA(25) TYPE C VALUE 'Static Variable'.
    CLASS-METHODS: STATMET.

ENDCLASS.                    "CLASS1 DEFINITION

*----------------------------------------------------------------------*
*       CLASS CLASS1 IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS CLASS1 IMPLEMENTATION.

  METHOD INSTMET.

    WRITE:/ STATDATA, INSTDATA.

  ENDMETHOD.                    "INSTMET

  METHOD STATMET.

    WRITE:/ STATDATA.

  ENDMETHOD.                    "STATMET

ENDCLASS.                    "CLASS1 IMPLEMENTATION

START-OF-SELECTION.

  DATA: OREF TYPE REF TO CLASS1.

  CREATE OBJECT OREF.

  CALL METHOD CLASS1=>STATMET.

  CALL METHOD OREF->INSTMET.

OOPS-4







METHOD GET_MATERIAL.

  DATA: G_MATNR TYPE MARA-MATNR.

  SELECT SINGLE MATNR FROM MARA
               INTO G_MATNR
               WHERE MATNR = P_MATNR.

  IF SY-SUBRC = 0.

    SELECT MATNR
           ERNAM
           MATKL FROM MARA
                 INTO TABLE IT_MARA
                WHERE MATNR = P_MATNR.
  ELSE.

    RAISE MATERIAL_NOTFOUND.

  ENDIF.

ENDMETHOD.

REPORT  ZO_CLASS4.

PARAMETERS: P_MATNR TYPE MARA-MATNR.

TYPES: BEGIN OF T_MARA,
        MATNR LIKE MARA-MATNR,
        ERNAM LIKE MARA-ERNAM,
        MATKL LIKE MARA-MATKL,
       END OF T_MARA.

DATA: IT_MARA TYPE STANDARD TABLE OF T_MARA,
      WA_MARA LIKE LINE OF IT_MARA.

START-OF-SELECTION.

  DATA: OREF TYPE REF TO ZO_CLASS5.

  CREATE OBJECT OREF.

  CALL METHOD OREF->GET_MATERIAL
    EXPORTING
      P_MATNR           = P_MATNR
    IMPORTING
      IT_MARA           = IT_MARA
    EXCEPTIONS
      MATERIAL_NOTFOUND = 1
      OTHERS            = 2.
  IF SY-SUBRC <> 0.
    MESSAGE ID 'ZACLASS' TYPE 'I' NUMBER '000'
               WITH P_MATNR.

  ELSE.

    LOOP AT IT_MARA INTO WA_MARA.

      WRITE:/ WA_MARA-MATNR, WA_MARA-ERNAM, WA_MARA-MATKL.

    ENDLOOP.


  ENDIF.