Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Help in User Exit

Former Member
0 Kudos

Hi,

There is user exit that bring table i_t_data with org.unit and dates ,

the problem is that the table dont bring all the org units we have, my qustion is how i now where this table become filled ?

i new in this topic i give more details maybe it helps,

ZXRSAU02 the name of user exit and inside i have this call

WHEN '0ORGUNIT_ATTR'.

LOOP AT I_T_DATA INTO LW_T_DATA_0ORG

......

and when i go to tables tab in EXIT_SAPLRSAP_002

the table I_T_DATA dont have type or associated type just short text of

Transferred Data .

i check in all code thare is no place for insert modify or append to this table ,

i use rsa3 from bw to run this exit with no input in input fields.

Thankes

1 ACCEPTED SOLUTION

ferry_lianto
Active Contributor
0 Kudos

Hi,

1. is how i now which org.unit is vaild or not becose i think i get to much org in table, for 4000 emp i get 2100 org i think is to much.

Do you have any logic/criteria to filter table IT_ORGUNITS in order to get the missing org. unit? If you do then perhaps you can narrow down the return values of org. unit.

2 .how i add the dates to org.

like in i_t_data i have

datefrom dateto org

20020627 99991231 50200828

You can do something like this assuming you are able to get the missing org. unit.


DATA: L_T_ORGUNIT LIKE HRMS_BW_IO_ORGUNIT OCCURS 0 WITH HEADER LINE.
DATA: IT_ORGUNITS LIKE HROBJECT OCCURS 0 WITH HEADER LINE.

DATA:  WA_ORGUNIT LIKE HRMS_BW_IO_ORGUNIT. 
                           
CASE I_DATASOURCE.
  WHEN '0ORGUNIT_ATTR'.
    L_T_ORGUNIT[] = I_T_DATA[].
                                                                        
    CALL FUNCTION 'HR_BW_GET_OBJECTS'
      EXPORTING
        I_CHABASNM = '0ORGUNIT'
        BEGDA      = SY-DATUM
        ENDDA      = SY-DATUM
      TABLES
        OBJECTS    = IT_ORGUNITS
      EXCEPTIONS
        NOT_FOUND  = 1
        OTHERS     = 2.
                                                                        
    LOOP AT  IT_ORGUNITS.
* New logic to filter out the missing org. unit       
      ....
    ENDLOOP.
     
    WA_ORGUNIT-DATEFROM = '20020627'.
    WA_ORGUNIT-DATETO = '99991231'.
    WA_ORGUNIT-ORGEH = '50200828'.
    INSERT WA_ORGUNIT INTO TABLE L_T_ORGUNIT.
 
    I_T_DATA[] = L_T_ORGUNIT[].

Regards,

Ferry Lianto

12 REPLIES 12

Former Member
0 Kudos

Hi,

Can you please send me the code in between

WHEN '0ORGUNIT_ATTR'.

..............

................

when <data source>.

i just want to see the code how it has been written and why it is not transfering the values.

Satish

0 Kudos

hi satish

my qustion is where<b> i_t_data</b> is field if u see in WHEN '0ORGUNIT_ATTR' place

i have to find all the manager of org.unit in table i_t_data but one org.unit is miss

and i dont now where i_t_data is filled.

take a look of this:



FUNCTION EXIT_SAPLRSAP_002.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"       IMPORTING
*"             VALUE(I_DATASOURCE) TYPE  RSAOT_OLTPSOURCE
*"             VALUE(I_CHABASNM) TYPE  SBIWA_S_INTERFACE-CHABASNM
*"             VALUE(I_UPDMODE) TYPE  SBIWA_S_INTERFACE-UPDMODE
*"       TABLES
*"              I_T_SELECT TYPE  SBIWA_T_SELECT
*"              I_T_FIELDS TYPE  SBIWA_T_FIELDS
*"              I_T_DATA              
*"              C_T_MESSAGES STRUCTURE  BALMI OPTIONAL
*"       EXCEPTIONS
*"              RSAP_CUSTOMER_EXIT_ERROR
*"----------------------------------------------------------------------
 
 
  INCLUDE ZXRSAU02.

double click on ZXRSAU02


&---------------------------------------------------------------------*
*&  Include           ZXRSAU02
*&---------------------------------------------------------------------*
 
* DATA FOR THE ADDITIONAL FIELDS IN 0EMPLOYEE_ATTR.
TYPES: BEGIN OF t_pa0105,
        usrty LIKE pa0105-usrty,
        endda LIKE pa0105-endda,
        usrid LIKE pa0105-usrid,
        usrid_long LIKE pa0105-usrid_long,                
      END OF t_pa0105.
DATA: lt_pa0105 TYPE TABLE OF t_pa0105,
      lw_pa0105 LIKE LINE OF lt_pa0105,
      lc_t_data_0emp TYPE TABLE OF hrms_biw_io_occupancy,
      lw_t_data_0emp LIKE LINE OF lc_t_data_0emp.
 
DATA: l_sobid LIKE hrp1001-sobid.
*data for the managed kostl and orgunit. 
TYPES: BEGIN OF t_relat,
        relat LIKE hrp1001-relat,
        sobid LIKE hrp1001-sobid,
      END OF t_relat.
DATA: lt_relat TYPE TABLE OF t_relat,
      lw_relat LIKE LINE OF lt_relat.
 
*data for org unit
TYPES: BEGIN OF t_relat_org,
        begda LIKE hrp1001-begda,                          
        endda LIKE hrp1001-endda,
        sobid LIKE hrp1001-sobid,
      END OF t_relat_org.
DATA: lt_relat_org TYPE TABLE OF t_relat_org,
      lw_relat_org LIKE LINE OF lt_relat_org,
      lc_t_data_0org TYPE TABLE OF hrms_bw_io_orgunit,
      lw_t_data_0org LIKE LINE OF lc_t_data_0org.
DATA: l_plans LIKE pa0001-plans.
CASE i_datasource.
  WHEN '0EMPLOYEE_ATTR'.
*grtting the relevant data from the infotype
    LOOP AT i_t_data INTO lw_t_data_0emp.
      SELECT endda
             usrty usrid usrid_long
      FROM pa0105
      INTO CORRESPONDING FIELDS OF TABLE lt_pa0105
      WHERE pernr EQ lw_t_data_0emp-pernr
        AND endda GE lw_t_data_0emp-begda
        AND begda LE lw_t_data_0emp-endda
 
        AND usrty IN ('0002','0003','0004','0006','0010','0022')."20.04.07
      SORT lt_pa0105 BY usrty endda DESCENDING.
*adding the data
      CLEAR lw_pa0105.
      READ TABLE lt_pa0105 WITH KEY usrty = '0002' INTO lw_pa0105.
      lw_t_data_0emp-zz0phone = lw_pa0105-usrid.
      CLEAR lw_pa0105.
      READ TABLE lt_pa0105 WITH KEY usrty = '0003' INTO lw_pa0105.
      lw_t_data_0emp-zz0me_telno_p = lw_pa0105-usrid.
 
      CLEAR lw_pa0105.
      READ TABLE lt_pa0105 WITH KEY usrty = '0004' INTO lw_pa0105.
      IF sy-subrc EQ '0'.
        lw_t_data_0emp-zz0me_telno_w = lw_pa0105-usrid.
      ELSE.
        CLEAR lw_pa0105.
        READ TABLE lt_pa0105 WITH KEY usrty = '0006' INTO lw_pa0105.
        lw_t_data_0emp-zz0me_telno_w = lw_pa0105-usrid.
      ENDIF.
      CLEAR lw_pa0105.
 
      READ TABLE lt_pa0105 WITH KEY usrty = '0010' INTO lw_pa0105.
      lw_t_data_0emp-zz0mail = lw_pa0105-usrid_long.
      CLEAR lw_pa0105.
      SELECT SINGLE plant
      FROM pa9001
      INTO lw_t_data_0emp-zz0location
      WHERE pernr EQ lw_t_data_0emp-pernr
        AND endda GE lw_t_data_0emp-begda
        AND begda LE lw_t_data_0emp-endda.              
 
      READ TABLE lt_pa0105 WITH KEY usrty = '0022' INTO lw_pa0105.
      lw_t_data_0emp-zz0me_telno_e = lw_pa0105-usrid.
      CLEAR lw_pa0105.
 
      SELECT SINGLE trfgr
      FROM pa0008
      INTO lw_t_data_0emp-zztrfgr
      WHERE pernr EQ lw_t_data_0emp-pernr
        AND endda GE lw_t_data_0emp-begda
        AND begda LE lw_t_data_0emp-endda.
 
      SELECT relat sobid
      FROM hrp1001
      INTO TABLE lt_relat
      WHERE objid EQ lw_t_data_0emp-plans
        AND rsign EQ 'A'
        AND ( relat EQ '011' OR relat EQ '012' )
        AND endda GE lw_t_data_0emp-begda
        AND begda LE lw_t_data_0emp-endda.
      CLEAR lw_relat.
      READ TABLE lt_relat WITH KEY relat = '011' INTO lw_relat.
      lw_t_data_0emp-zzmankostl = lw_relat-sobid.
      CLEAR lw_relat.
      READ TABLE lt_relat WITH KEY relat = '012' INTO lw_relat.
      lw_t_data_0emp-zzmanorgeh = lw_relat-sobid.
 
 
 
      APPEND lw_t_data_0emp TO lc_t_data_0emp.
 
    ENDLOOP.
*adding the data to the table
    FREE i_t_data.
    i_t_data[] = lc_t_data_0emp[].
 
 
*adding manager of orgunit to orgunit attribute
  WHEN '0ORGUNIT_ATTR'.
 

 
    DATA: tmp_sobid TYPE sobid,
          l_begda TYPE sy-datum,
          l_endda TYPE sy-datum.
 
 
 
 
 
    LOOP AT i_t_data INTO lw_t_data_0org.  "where i_t_data is filled ?
 
      SELECT begda endda sobid
      FROM hrp1001
      INTO TABLE lt_relat_org
      WHERE objid EQ lw_t_data_0org-orgeh
        AND rsign EQ 'B'
        AND relat EQ '012'
        AND plvar = '01'
        AND endda GE sy-datum
        AND begda LE sy-datum.
 
 
      SORT lt_relat_org BY  begda DESCENDING endda DESCENDING sobid.
 
      CLEAR lw_relat_org.
 
      READ TABLE lt_relat_org INDEX 1 INTO lw_relat_org.
 
      IF sy-subrc EQ '0'.
 
        SELECT SINGLE sobid begda endda
          FROM hrp1001
          INTO (tmp_sobid ,l_begda,l_endda)
          WHERE objid = lw_relat_org-sobid
          AND relat = '008'
          AND rsign = 'A'
          AND endda GE sy-datum
          AND begda LE sy-datum.
.
 
 
        IF sy-subrc = 0.
 
 
          MOVE: tmp_sobid TO lw_t_data_0org-zzmanager,
                lw_relat_org-begda to lw_t_data_0org-datefrom,
                lw_relat_org-endda to lw_t_data_0org-dateto.
 
 
          APPEND lw_t_data_0org TO lc_t_data_0org.
          CLEAR: tmp_sobid,lw_t_data_0org-zzmanager.
 
        ENDIF.
      ENDIF.
    ENDLOOP.
 
 
    SORT   lc_t_data_0org BY orgeh.
    DELETE ADJACENT DUPLICATES FROM  lc_t_data_0org.
 
 
    FREE i_t_data.
    i_t_data[] = lc_t_data_0org[].
 
ENDCASE.



Regards

0 Kudos

Hi,

Can you please keep a break point at below statement

i_t_data[] = lc_t_data_0org[].

once this statement gets executed check whether the internal table i_t_data has data or not. and also check it is having all the org. units.

Satish

Message was edited by:

Satish Panakala

0 Kudos

hi satish

i do that and i still miss one org.unit i check in pp01 and the org.is valid

thankes

ferry_lianto
Active Contributor
0 Kudos

Hi,

When you run RSA3 with data source 0ORGUNIT_ATTR without specifying ORGEH (Org Unit) in selection screen, the system will call FM HR_BW_GET_OBJECTS to get all org units based on DATEFROM and DATETO selection screen.

By the time, the system reaches user exits EXIT_SAPLRSAP_002, the internal table I_T_DATA should be populated with all values for field ORGEH.


DATA: L_T_ORGUNIT LIKE HRMS_BW_IO_ORGUNIT OCCURS 0 WITH HEADER LINE.

CASE I_DATASOURCE.
  WHEN '0ORGUNIT_ATTR'.
    L_T_ORGUNIT[] = I_T_DATA[].

    ...

ENDCASE.

Please debug the program and place break point at FM HR_BW_GET_OBJECTS to see whether the missing org. unit

is available or not.

Regards,

Ferry Lianto

0 Kudos

hi ferry

Thankes for your replay!

i have 2 qustion:

1.do u wont me to add the line of code u write?

2.when i use rsa3 i dont choose date or something else if i do so i supposed to get all the org.unit in my org ?

Best Regards

ferry_lianto
Active Contributor
0 Kudos

Hi,

1. do u wont me to add the line of code u write?

Well ... you can use my code to add the missing org. unit into internal table I_T_DATA by calling FM HR_BW_GET_OBJECTS.

Did you get the missing org. unit when run FM HR_BW_GET_OBJECTS?

2. when i use rsa3 i dont choose date or something else if i do so i supposed to get all the org.unit in my org ?

Yes ... you should get all org. unit when DATEFROM and DATETO are not provided in selection screen. The system will use '19000101' and '99991231' for date range default.

Regards,

Ferry Lianto

0 Kudos

Hi Ferry

how i can use this function in my program ,what i have to put in i_chabasnm ?

and whaen i use the u wont me to append the line that the Fm bring to i_t_data?

Thankes

&Best Regards

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please try this.


DATA: L_T_ORGUNIT LIKE HRMS_BW_IO_ORGUNIT OCCURS 0 WITH HEADER LINE.
DATA: IT_ORGUNITS LIKE HROBJECT OCCURS 0 WITH HEADER LINE.
                                                                        
CASE I_DATASOURCE.
  WHEN '0ORGUNIT_ATTR'.
    L_T_ORGUNIT[] = I_T_DATA[].
                                                                        
    CALL FUNCTION 'HR_BW_GET_OBJECTS'
      EXPORTING
        I_CHABASNM = '0ORGUNIT'
        BEGDA      = SY-DATUM
        ENDDA      = SY-DATUM
      TABLES
        OBJECTS    = IT_ORGUNITS
      EXCEPTIONS
        NOT_FOUND  = 1
        OTHERS     = 2.
                                                                        
   ...

Regards,

Ferry Lianto

0 Kudos

hi Ferry

Thanks i use that and i see the all org.unit in prod i get about 2100 enteries and the org.unit i miss is there !

my qustions:

1. is how i now which org.unit is vaild or not becose i think i get to much org in table, for 4000 emp i get 2100 org i think is to much .

2.how i add the dates to org.

like in i_t_data i have

datefrom dateto org

20020627 99991231 50200828

thanks you are great u are the only only that really help in this form

thanks again.

Best Regards

ferry_lianto
Active Contributor
0 Kudos

Hi,

1. is how i now which org.unit is vaild or not becose i think i get to much org in table, for 4000 emp i get 2100 org i think is to much.

Do you have any logic/criteria to filter table IT_ORGUNITS in order to get the missing org. unit? If you do then perhaps you can narrow down the return values of org. unit.

2 .how i add the dates to org.

like in i_t_data i have

datefrom dateto org

20020627 99991231 50200828

You can do something like this assuming you are able to get the missing org. unit.


DATA: L_T_ORGUNIT LIKE HRMS_BW_IO_ORGUNIT OCCURS 0 WITH HEADER LINE.
DATA: IT_ORGUNITS LIKE HROBJECT OCCURS 0 WITH HEADER LINE.

DATA:  WA_ORGUNIT LIKE HRMS_BW_IO_ORGUNIT. 
                           
CASE I_DATASOURCE.
  WHEN '0ORGUNIT_ATTR'.
    L_T_ORGUNIT[] = I_T_DATA[].
                                                                        
    CALL FUNCTION 'HR_BW_GET_OBJECTS'
      EXPORTING
        I_CHABASNM = '0ORGUNIT'
        BEGDA      = SY-DATUM
        ENDDA      = SY-DATUM
      TABLES
        OBJECTS    = IT_ORGUNITS
      EXCEPTIONS
        NOT_FOUND  = 1
        OTHERS     = 2.
                                                                        
    LOOP AT  IT_ORGUNITS.
* New logic to filter out the missing org. unit       
      ....
    ENDLOOP.
     
    WA_ORGUNIT-DATEFROM = '20020627'.
    WA_ORGUNIT-DATETO = '99991231'.
    WA_ORGUNIT-ORGEH = '50200828'.
    INSERT WA_ORGUNIT INTO TABLE L_T_ORGUNIT.
 
    I_T_DATA[] = L_T_ORGUNIT[].

Regards,

Ferry Lianto

0 Kudos

hi Ferry

what i meant is to get the valid date for org.unit from maybe hrp1000 table

but i take care of that tanks for all of your Replay

Best regards