SAP for Higher Education and Research Discussions
Spark conversations about student engagement, research optimization, and administrative efficiency using SAP in higher education and research. Join in!
cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI for create a student

former_member300754
Participant
0 Kudos

hi all,

does anyone familiar with BAPI which create student?

I've found BAPI_STUDENT_CREATEFROMDATA3 but it works for RFC.

Any idea on this. Thanks in advance.

Regards,

Peerasit

1 ACCEPTED SOLUTION

michael_hobbins
Active Participant
0 Kudos

Hello Peerasit,

we've been using the BAPI/RFC for many years with no problems. Being an RFC, you can use it from an external application, but no only from external applications. Actualy, we call it from a local report.

In 2005 a new version was introduced, but the only "visible" change is a IMPORTING variable names UPDATEACCOUNTDATA, with "X" as default value. We haven't used it yet. I'm don't know if there are any other new versions. What ERP/SLcM version are you using?

As we don't use the admission process in SAP, once the student is admitted, we call the BAPI and create the student. The data for input we use is:

  • document number

  • personal data

  • organizational unit info

  • fee calculation data

  • study data

The data we get back from it is: student object ID assigned, and data for the business partner number.

Remember to check the RETURN table for any messages, and remember to call BAPI_TRANSACTION_COMMIT to commit changes after using BAPIs.

If you check documentation of the BAPI (TX SE37, insert BAPI name, menu option Goto->Documentation->Function Module documentation ) you'll find quite usefull information about each of the parameteres, plus some notes on use.

If you want some code example, I can post part of ours.

In https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/10e6d57f-c509-2b10-11a5-c35a3807... (page 6) you can find the following tips:

2.2.1 Data Migration for Student Data

Student data should be migrated using the BAPIs or RFC-enabled function modules provided by Student Lifecycle Management.

u2022 Check the data transfer guideline in the SAP Service Marketplace

u2022 As the student business partner record uses a combination of the BDT Framework and the HCM framework, student records must be created using BAPI_STUDENT_CREATEFROMDATA3

u2022 For student admission and registration data the function module HRIQ_STUDENT_STUDIES_DT_RFC should be used

Hints for programmers of data transfer programs:

u2022 Avoid nested loops over internal tables in your data transfer programs

u2022 Use packages for the database update if possible

u2022 Do a performance trace for your data transfer programs.

u2022 Check that the run time increases at the worst linear with increasing package sizes

Regards

Michael

View solution in original post

7 REPLIES 7

michael_hobbins
Active Participant
0 Kudos

Hello Peerasit,

we've been using the BAPI/RFC for many years with no problems. Being an RFC, you can use it from an external application, but no only from external applications. Actualy, we call it from a local report.

In 2005 a new version was introduced, but the only "visible" change is a IMPORTING variable names UPDATEACCOUNTDATA, with "X" as default value. We haven't used it yet. I'm don't know if there are any other new versions. What ERP/SLcM version are you using?

As we don't use the admission process in SAP, once the student is admitted, we call the BAPI and create the student. The data for input we use is:

  • document number

  • personal data

  • organizational unit info

  • fee calculation data

  • study data

The data we get back from it is: student object ID assigned, and data for the business partner number.

Remember to check the RETURN table for any messages, and remember to call BAPI_TRANSACTION_COMMIT to commit changes after using BAPIs.

If you check documentation of the BAPI (TX SE37, insert BAPI name, menu option Goto->Documentation->Function Module documentation ) you'll find quite usefull information about each of the parameteres, plus some notes on use.

If you want some code example, I can post part of ours.

In https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/10e6d57f-c509-2b10-11a5-c35a3807... (page 6) you can find the following tips:

2.2.1 Data Migration for Student Data

Student data should be migrated using the BAPIs or RFC-enabled function modules provided by Student Lifecycle Management.

u2022 Check the data transfer guideline in the SAP Service Marketplace

u2022 As the student business partner record uses a combination of the BDT Framework and the HCM framework, student records must be created using BAPI_STUDENT_CREATEFROMDATA3

u2022 For student admission and registration data the function module HRIQ_STUDENT_STUDIES_DT_RFC should be used

Hints for programmers of data transfer programs:

u2022 Avoid nested loops over internal tables in your data transfer programs

u2022 Use packages for the database update if possible

u2022 Do a performance trace for your data transfer programs.

u2022 Check that the run time increases at the worst linear with increasing package sizes

Regards

Michael

0 Kudos

Hi Michael,

I've checked BAPI_STUDENT_CREATEFROMDATA3 thru SE37 and I execute/run thru SE37. I fill out the mandatory fields (FIRST_NAME, LAST_NAME, and CORRESP_LANGUAGE). After that, i get the PLANVERSION, OBJECTID, STUDENTNUMBER, and BUSINESSPARTNER, and the result of return shows the message like the following "Student 0120001124 has been created. External reference: 100000448".

Unfortunately, I cannot see a new student even on Student File (PIQST00) or PP01.

Please advise me on this.

Thanks in advance,

Peerasit

0 Kudos

Hi Peerasit,

that's correct, the student will not appear. Not until you execute the the commit function module BAPI_TRANSACTION_COMMIT.

I had exactly the same problem when I started to use it, until I was adviced about BAPI_TRANSACTION_COMMIT. I'm not sure if it will work executed from SE37, but give it a try.

Here's a part of our code, we even use an extra BAPI to insert addresses/telehones/faxes right before we commit changes:

CALL FUNCTION 'BAPI_STUDENT_CREATEFROMDATA3'
           EXPORTING
                studentnumberextern = ci
                studentpersonaldata = studentpersonaldata
                studentorgunit      = studentorgunit
                studentfeedata      = studentfeedata
                studentstudydata    = studentstudydata
           IMPORTING
                objectid            = objectid
                businesspartner     = businesspartner
           TABLES
                return              = return.

  IF ( sy-subrc = 0 ) AND ( objectid <> '00000000' ).
   ....
        CALL FUNCTION 'BAPI_STUDENT_ADDRESS_ADD'
             EXPORTING
                  planversion = '01'
                  objectid    = objectid
                  addressdata = addressdata
             TABLES
                  bapiadtel   = auxbapiadtel
                  bapiadfax   = auxbapiadfax.

        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
             TABLES
                  return = return2.
  endif.

After this, you get the student created and visible from PIQSTD, PIQST00, etc.

Hope this helps

Regards

Michael

0 Kudos

Hi Michael,

Thanks for your advise. Anyway, i need a bit help. As i try to create a program to get the parameters from screen and call functions "BAPI_STUDENT_CREATEFROMDATA3". I get a short dump error, i guess the error is from


Runtime Errors         CALL_FUNCTION_CONFLICT_TYPE
Except.                CX_SY_DYN_CALL_ILLEGAL_TYPE

*Short text*
    Type conflict when calling a function module.



*What happened?*
    Error in the ABAP Application Program

    The current ABAP program "ZTEST" had to be terminated because it has
    come across a statement that unfortunately cannot be executed.

    A function module was called incorrectly.

*Error analysis*
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SY_DYN_CALL_ILLEGAL_TYPE', was
     not caught and
    therefore caused a runtime error.
    The reason for the exception is:
    The call to the function module "BAPI_STUDENT_CREATEFROMDATA3" is incorrect:

    The function module interface allows you to specify only
    fields of a particular type under "STUDENTPERSONALDATA".
    The field "GI_STUDENTDATA" specified here is a different
    field type
    .

it seems like export the invalid type of structure. The following is my code, please take a look and give me the advise:



data: gt_studentdata type BAPISTUDENT_PERSONAL,
      gi_studentdata like table of gt_studentdata,
      gw_studentdata like line of gi_studentdata.

*--- Import
data: gv_PLANVERSION type BAPISTUDENT_HEAD-PLVAR,          " Plan Version
      gv_OBJECTID type BAPISTUDENT_HEAD-OBJID,             " Object ID of Student
      gv_STUDENTNUMBER type BAPISTUDENT_HEAD-STUDENTNUMBER," Student Number
      gv_BUSINESSPARTNER type BAPISTUDENT_HEAD-PARTNER.    " Student Business Partner Number

*--- Return
data: t_return type BAPIRET2 OCCURS 0.

SELECTION-SCREEN begin of BLOCK b1 with FRAME TITLE text-001.
PARAMETERS: p_FNAME type PAD_VORNA,
            p_LNAME type PAD_NACHN, "'Doe',
            p_LANGU type PIQ_SPRAS, "= 'E'.
            p_TITEL type BAPISTUDENT_PERSONAL-TITEL.
SELECTION-SCREEN end of BLOCK b1.

BREAK-POINT.
gw_studentdata-FIRST_NAME = p_fname.
gw_studentdata-LAST_NAME = p_lname.
gw_studentdata-CORRESP_LANGUAGE = p_langu.

append gw_studentdata to gi_studentdata.

CALL FUNCTION 'BAPI_STUDENT_CREATEFROMDATA3'
  EXPORTING
*   VALIDITYBEGIN               = SY-DATUM
*   OBJECTIDEXTERN              =
*STUDENTNUMBEREXTERN         = 
    STUDENTPERSONALDATA         = gi_studentdata
*   STUDENTADDITIONALDATA       =
*   STUDENTCHALLENGEDATA        =
*   STUDENTRESIDENCYDATA        =
*   STUDENTSTUDYDATA            =
*   STUDENTFEEDATA              =
*   STUDENTORGUNIT              =
*   STUDENTCAMPUS               =
*   STUDENTSTATUSDATA           =
*   TESTRUN                     = ' '
*   UPDATEACCOUNTDATA           = 'X'
 IMPORTING
   PLANVERSION                 = gv_PLANVERSION
   OBJECTID                    = gv_OBJECTID
   STUDENTNUMBER               = gv_STUDENTNUMBER
   BUSINESSPARTNER             = gv_BUSINESSPARTNER
  TABLES
    RETURN                      = t_return
*   EXTENSIONIN                 =
          .

I'm looking forward to hearing the solution from you. Million thanks in advance,

Peerasit

0 Kudos

Hi Peerasit,

you're right, the problem is on the structure type. When you call functions, the data or structure type used MUST BE THE EXACTLY THE SAME as the expected by the function module.

So instead of having

data: ...
      gi_studentdata like table of gt_studentdata,

Put

gi_studentdata TYPE  BAPISTUDENT_PERSONAL,

Please check this for all you IMPORTS, EXPORTS, CHANGES and TABLES you'll be using.

This is our code:

DATA: studentpersonaldata TYPE bapistudent_personal.

 ....
    studentpersonaldata-first_name = nom.  "first name
    studentpersonaldata-last_name = ape.   "surname
    studentpersonaldata-persidno = ci.         "personal ID

.....
    studentpersonaldata-corresp_language = 'EN'.
    IF fechanac <> '' AND fechanac <> '00000000'.    "checking birthdate
      studentpersonaldata-date_birth = fechanac.
    ELSE.
      studentpersonaldata-date_birth = '19000101'.
      WRITE:
     'Atención: no tiene fecha de nacimiento, se le ingresa 01.01.1900'.
    ENDIF.

    studentpersonaldata-nickname = id_crm.

    IF sexo = 'M'.
      studentpersonaldata-gender_key = '1'.                 "1 = Male
    ELSE.
      studentpersonaldata-gender_key = '2'.                 "2 = Female
    ENDIF.

Regards

Michael

0 Kudos

Hi Jeroen and Michael,

Thank you so much for your help. The problem has been solved.

Thanks again.

Peerasit

Former Member
0 Kudos

Why don't you to a cross reference on the function module and see how other program call this FM (SE37, BAPI_STUDENT_CREATEFROMDATA3 --> Utilities --> Whers Used List) --> . In that case you see that your type definition is wrong (as stated in the short dump):

gi_studentdata like table of gt_studentdata,

Should be:

ls_bapipersonal LIKE bapistudent_personal,

The importing parameter STUDENTPERSONALDATA of the FM is a structure...not a table.

Jeroen