Application Development and Automation 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: 
Read only

ABAP Object Class

Former Member
0 Likes
1,225

Hi Experts,

Need an advise on the following codes.

TYPES: BEGIN OF gty_obj,

           PLVAR TYPE hrp1001-PLVAR,

           OTYPE TYPE hrp1001-OTYPE,         

           objid TYPE hrp1001-objid,

      END OF gty_obj.

TYPES: gtab_obj TYPE STANDARD TABLE OF gty_obj INITIAL SIZE 0.

DATA: gt_obj TYPE gtab_obj.

DATA: candidate type ref to CL_HRRCF_CANDIDATE_PREVIEW_BL.

CALL METHOD candidate->GET_PERSONAL_DATA

  EXPORTING

    CAND_OBJ      = gt_obj.

Keep getting below error message:

"GT_OBJ" is not type-compatible with formal parameter "CAND_OBJ".

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,154

CAND_OBJ is a structure of hrobject. Try this one:


DATA:

  o_candidate TYPE REF TO cl_hrrcf_candidate_preview_bl.

DATA

  w_cand_obj TYPE hrobject.

START-OF-SELECTION.

  CREATE OBJECT o_candidate.

  CALL METHOD o_candidate->get_personal_data

    EXPORTING

      cand_obj = w_cand_obj.

6 REPLIES 6
Read only

nmkarthikeya
Active Participant
0 Likes
1,154

Looks like CAND_OBJ is a structure and not internal table.

Try declaring any one of below way.

TYPES: gt_obj TYPE gty_obj.

Types: gt_obj type HROBJECT.

Regards,

Karthikeya

Read only

Former Member
0 Likes
1,155

CAND_OBJ is a structure of hrobject. Try this one:


DATA:

  o_candidate TYPE REF TO cl_hrrcf_candidate_preview_bl.

DATA

  w_cand_obj TYPE hrobject.

START-OF-SELECTION.

  CREATE OBJECT o_candidate.

  CALL METHOD o_candidate->get_personal_data

    EXPORTING

      cand_obj = w_cand_obj.

Read only

Former Member
0 Likes
1,154

Hi,


- Not sure why tou have created "types: gty_obj" when SAP has provided HROBJECT see se11. You should also use gt_obj type STANDARD TABLE OF HROBJECT.
- For you coding try passing "get_obj[]".

CALL METHOD candidate->GET_PERSONAL_DATA

  EXPORTING

    CAND_OBJ      = gt_obj[].

Hope it helps.

Read only

Former Member
0 Likes
1,154

Hi All,

Thank you. But receive another error message:

You cannot create an instance of the class "CL_HRRCF_CANDIDATE_PREVIEW_BL" outside the class.

If comment this line: CREATE OBJECT o_candidate and execute the program. The below error message occur:

Pls help

Regards,

TCL

Read only

Former Member
0 Likes
1,154

As the CL_HRRCF_CANDIDATE_PREVIEW_BL is a Private class, create instance as follows..

CALL METHOD cl_hrrcf_candidate_preview_bl=>get_instance

             IMPORTING

                   result = o_candidate.

Regards

Read only

0 Likes
1,154

Hi All,

Thank you for all the solutions.

Regards,

TCL