SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

BAPI_APPLICANT_CREATE



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sat Apr 12, 2008 5:46 pm    Post subject: BAPI_APPLICANT_CREATE Reply with quote

BAPI_APPLICANT_CREATE - Create from data

Code:
BEGIN_METHOD CREATEFROMDATA CHANGING CONTAINER.
DATA:
      APPLICANTGROUP LIKE BAPIAPLORG-AP_GROUP,
      APPLICANTSUBGROUP LIKE BAPIAPLORG-AP_SUBGRP,
      PERSONELAREA LIKE BAPIAPLORG-PERS_AREA,
      PERSONALSUBAREA LIKE BAPIAPLORG-P_SUBAREA,
      PERSONNEL LIKE BAPIAPLORG-PERSONNEL,
      FIRSTOFADRESSKEY LIKE BAPIAPLPER-FOA_KEY,
      FIRSTNAME LIKE BAPIAPLPER-F_NAME,
      LASTNAME LIKE BAPIAPLPER-L_NAME,
      MAIDENNAME LIKE BAPIAPLPER-BIRTHNAME,
      SECONDLASTNAME LIKE BAPIAPLPER-LAST_NAME2,
      KNOWNAS LIKE BAPIAPLPER-KNOWN_AS,
      SSN LIKE BAPIAPLPER-SSN,
      DATEOFBIRTH LIKE BAPIAPLPER-B_DATE,
      TITLE LIKE BAPIAPLPER-TITLE,
      TITLE2 LIKE BAPIAPLPER-2ND_TITLE,
      ARISTOCRATICTITLE LIKE BAPIAPLPER-ARI_TITLE,
      AFFIX LIKE BAPIAPLPER-AFFIX,
      PREFIX2 LIKE BAPIAPLPER-PREFIX_2,
      GENDER LIKE BAPIAPLPER-GENDER,
      PLACEOFBIRTH LIKE BAPIAPLPER-BIRTHPLACE,
      MARITALSTATUS LIKE BAPIAPLPER-MAR_STAT,
      INITIALS LIKE BAPIAPLPER-INITIALS,
      NATION LIKE BAPIAPLPER-NATION,
      LETTERLANGUAGE LIKE BAPIAPLPER-LANGU,
      CO LIKE BAPIAPLADR-C_O,
      STREET LIKE BAPIAPLADR-STREET,
      ADDRESS2NDLINE LIKE BAPIAPLADR-2ND_ADD_LN,
      CITY LIKE BAPIAPLADR-CITY,
      REGION LIKE BAPIAPLADR-REGION,
      DISTRICT LIKE BAPIAPLADR-DISTRICT,
      ZIPCODE LIKE BAPIAPLADR-PCD_CITY,
      COUNTRY LIKE BAPIAPLADR-CNTRY,
      TELEPHONNO LIKE BAPIAPLADR-TEL_NO,
      ADVERTISEMENT LIKE BAPIAPPLIC-ADVERT,
      UNSOLICITEDAPPLGROUP LIKE BAPIAPPLIC-UNSAPPGP,
      MEDIUM LIKE BAPIAPPLIC-MEDIUM,
      RETURN LIKE BAPIRETURN,
      EDUCATION LIKE BAPIEDUC OCCURS 0,
      PREVIOUSEMPLOYMENT LIKE BAPIEMPLOY OCCURS 0,
      QUALIFICATION LIKE BAPIQUALI OCCURS 0,
      VACANCYASSIGNMENT LIKE BAPIVACASS OCCURS 0,
      EMPLOYEENUMBER LIKE BAPIP0001-PERNR,                   "WBIK005689
      COMMUNICATIONTYPE LIKE BAPIP0105B-USERTYPE,            "WBIK005689
      EMAIL LIKE BAPIHR0105-E_MAIL.                          "WBIK005689
  SWC_GET_ELEMENT CONTAINER 'ApplicantGroup' APPLICANTGROUP.
  SWC_GET_ELEMENT CONTAINER 'ApplicantSubGroup' APPLICANTSUBGROUP.
  SWC_GET_ELEMENT CONTAINER 'PersonelArea' PERSONELAREA.
  SWC_GET_ELEMENT CONTAINER 'PersonalSubArea' PERSONALSUBAREA.
  SWC_GET_ELEMENT CONTAINER 'Personnel' PERSONNEL.
  SWC_GET_ELEMENT CONTAINER 'FirstOfAdressKey' FIRSTOFADRESSKEY.
  SWC_GET_ELEMENT CONTAINER 'FirstName' FIRSTNAME.
  SWC_GET_ELEMENT CONTAINER 'LastName' LASTNAME.
  SWC_GET_ELEMENT CONTAINER 'MaidenName' MAIDENNAME.
  SWC_GET_ELEMENT CONTAINER 'SecondLastName' SECONDLASTNAME.
  SWC_GET_ELEMENT CONTAINER 'KnownAs' KNOWNAS.
  SWC_GET_ELEMENT CONTAINER 'SSN' SSN.
  SWC_GET_ELEMENT CONTAINER 'DateOfBirth' DATEOFBIRTH.
  SWC_GET_ELEMENT CONTAINER 'Title' TITLE.
  SWC_GET_ELEMENT CONTAINER 'Title2' TITLE2.
  SWC_GET_ELEMENT CONTAINER 'AristocraticTitle' ARISTOCRATICTITLE.
  SWC_GET_ELEMENT CONTAINER 'Affix' AFFIX.
  SWC_GET_ELEMENT CONTAINER 'Prefix2' PREFIX2.
  SWC_GET_ELEMENT CONTAINER 'Gender' GENDER.
  SWC_GET_ELEMENT CONTAINER 'PlaceOfBirth' PLACEOFBIRTH.
  SWC_GET_ELEMENT CONTAINER 'MaritalStatus' MARITALSTATUS.
  SWC_GET_ELEMENT CONTAINER 'Initials' INITIALS.
  SWC_GET_ELEMENT CONTAINER 'Nation' NATION.
  SWC_GET_ELEMENT CONTAINER 'LetterLanguage' LETTERLANGUAGE.
  SWC_GET_ELEMENT CONTAINER 'CO' CO.
  SWC_GET_ELEMENT CONTAINER 'Street' STREET.
  SWC_GET_ELEMENT CONTAINER 'Address2ndLine' ADDRESS2NDLINE.
  SWC_GET_ELEMENT CONTAINER 'City' CITY.
  SWC_GET_ELEMENT CONTAINER 'Region' REGION.
  SWC_GET_ELEMENT CONTAINER 'District' DISTRICT.
  SWC_GET_ELEMENT CONTAINER 'ZipCode' ZIPCODE.
  SWC_GET_ELEMENT CONTAINER 'Country' COUNTRY.
  SWC_GET_ELEMENT CONTAINER 'TelephonNo' TELEPHONNO.
  SWC_GET_ELEMENT CONTAINER 'Advertisement' ADVERTISEMENT.
  SWC_GET_ELEMENT CONTAINER 'UnsolicitedApplGroup' UNSOLICITEDAPPLGROUP.
  SWC_GET_ELEMENT CONTAINER 'Medium' MEDIUM.
  SWC_GET_ELEMENT CONTAINER 'EmployeeNumber' EMPLOYEENUMBER. "WBIK005689
  SWC_GET_ELEMENT CONTAINER 'CommunicationType' COMMUNICATIONTYPE. "WBIK
  SWC_GET_ELEMENT CONTAINER 'EMail' EMAIL.                   "WBIK005689
  SWC_GET_TABLE CONTAINER 'Education' EDUCATION.
  SWC_GET_TABLE CONTAINER 'PreviousEmployment' PREVIOUSEMPLOYMENT.
  SWC_GET_TABLE CONTAINER 'Qualification' QUALIFICATION.
  SWC_GET_TABLE CONTAINER 'VacancyAssignment' VACANCYASSIGNMENT.
  CALL FUNCTION 'BAPI_APPLICANT_CREATE'
    EXPORTING
      2ND_ADD_LN = ADDRESS2NDLINE
      STREET = STREET
      C_O = CO
      LANGU = LETTERLANGUAGE
      NATION = NATION
      INITIALS = INITIALS
      MAR_STAT = MARITALSTATUS
      BIRTHPLACE = PLACEOFBIRTH
      CITY = CITY
      MEDIUM = MEDIUM
      UNSAPPGP = UNSOLICITEDAPPLGROUP
      ADVERT = ADVERTISEMENT
      TEL_NO = TELEPHONNO
      CNTRY = COUNTRY
      PCD_CITY = ZIPCODE
      DISTRICT = DISTRICT
      REGION = REGION
      GENDER = GENDER
      L_NAME = LASTNAME
      F_NAME = FIRSTNAME
      FOA_KEY = FIRSTOFADRESSKEY
      PERSONNEL = PERSONNEL
      P_SUBAREA = PERSONALSUBAREA
      PERS_AREA = PERSONELAREA
      AP_SUBGRP = APPLICANTSUBGROUP
      AP_GROUP = APPLICANTGROUP
      BIRTHNAME = MAIDENNAME
      SECONDNAME = SECONDLASTNAME
      PREFIX_2 = PREFIX2
      AFFIX = AFFIX
      ARI_TITLE = ARISTOCRATICTITLE
      2ND_TITLE = TITLE2
      KNOWN_AS = KNOWNAS
      SSN = SSN
      B_DATE = DATEOFBIRTH
      TITLE = TITLE
      EMPLOYEENUMBER = EMPLOYEENUMBER                        "WBIK005689
      COMMUNICATION_TYPE = COMMUNICATIONTYPE                 "WBIK005689
      E_MAIL = EMAIL                                         "WBIK005689
    IMPORTING
      RETURN = RETURN
      APPLICANTNUMBER = OBJECT-KEY-APPLICANTNUMBER
    TABLES
      VACANCY_ASSIGNMENT = VACANCYASSIGNMENT
      QUALIFICATION = QUALIFICATION
      PREVIOUS_EMPLOYMENT = PREVIOUSEMPLOYMENT
      EDUCATION = EDUCATION
    EXCEPTIONS
      OTHERS = 01.
  CASE SY-SUBRC.
    WHEN 0.            " OK
    WHEN OTHERS.       " to be implemented
  ENDCASE.
  SWC_SET_ELEMENT CONTAINER 'Return' RETURN.
  SWC_SET_TABLE CONTAINER 'Education' EDUCATION.
  SWC_SET_TABLE CONTAINER 'PreviousEmployment' PREVIOUSEMPLOYMENT.
  SWC_SET_TABLE CONTAINER 'Qualification' QUALIFICATION.
  SWC_SET_TABLE CONTAINER 'VacancyAssignment' VACANCYASSIGNMENT.
END_METHOD.


Also check the include "MPW12F01" for another sample code that SAP uses to create the applicant:
&---------------------------------------------------------------------
*&      Form  UPDATE_APPLICANT
&---------------------------------------------------------------------
FORM update_applicant.

  DATA: initdate LIKE p0022-begda.
  DATA: initquali LIKE p0024-quali.

  DATA: additional_suppress TYPE c VALUE 'X'.               "XDVN618851

  DATA: BEGIN OF tab OCCURS 5,
          subty LIKE t591a-subty,
        END OF tab.

  DATA: ind LIKE syst-index.

  DATA: BEGIN OF infty_0001 OCCURS 1.
          INCLUDE STRUCTURE p0001.
  DATA: END OF infty_0001.

  DATA: BEGIN OF infty_4001 OCCURS 1.
          INCLUDE STRUCTURE p4001.
  DATA: END OF infty_4001.

  DATA: BEGIN OF old_adr,
              stras    LIKE bapiapladr-street,
              name2    LIKE bapiapladr-c_o,
              locat    LIKE bapiapladr-2nd_add_ln,
              ort01    LIKE bapiapladr-city,
              ort02    LIKE bapiapladr-district,
        END   OF old_adr.

  DATA: BEGIN OF old_per,
              nachn    LIKE bapiaplper-l_name,
              vorna    LIKE bapiaplper-f_name,
              name2    LIKE bapiaplper-birthname,
              rufnm    LIKE bapiaplper-known_as,
              gbort    LIKE bapiaplper-birthplace,
        END   OF old_per.

  REFRESH education.    "LCP46C Note 204481

  LOOP AT tab0022.
    CHECK tab0022-begda NE initdate.
    CLEAR education.
    MOVE  tab0022-begda TO education-from_date.
    MOVE  tab0022-endda TO education-to_date.
    MOVE  tab0022-insti TO education-institute.
    MOVE  tab0022-slabs TO education-certific.
    MOVE  tab0022-slart TO education-educ_est.
    MOVE  tab0022-sland TO education-cntry.
    MOVE  tab0022-sltp1 TO education-br_study_1.
    MOVE  tab0022-sltp2 TO education-br_study_2.
    MOVE  tab0022-emark TO education-mark.                  "4.6C
    APPEND education.
  ENDLOOP.
  IF sy-subrc NE 0.                                         "4.6C
    REFRESH education. CLEAR education.                     "4.6C
  ENDIF.                                                    "4.6C
  REFRESH employer.    "LCP46C Note 204481
  LOOP AT tab0023.
    CHECK tab0023-begda NE initdate.
    CLEAR employer.
    MOVE tab0023-begda TO  employer-from_date.
    MOVE tab0023-endda TO  employer-to_date.
    MOVE tab0023-arbgb TO  employer-employer.
    MOVE tab0023-land1 TO  employer-cntry.
    MOVE tab0023-ort01 TO  employer-city.
    MOVE tab0023-taete TO  employer-job.
    MOVE tab0023-ansvx TO  employer-employment_contract.    "4.6C
    APPEND employer.
  ENDLOOP.
  IF sy-subrc NE 0.                                         "4.6C
    REFRESH employer. CLEAR employer.                       "4.6C
  ENDIF.                                                    "4.6C
  REFRESH qualification.    "LCP46C Note 204481
  LOOP AT tab0024.
    CHECK tab0024-quali NE initquali.
    CLEAR qualification.
    MOVE tab0024-quali TO qualification-qualif.

*MOVE TAB0024-AUSPR TO QUALIFICATION-PROFIC.             "XCZK034654

    MOVE tab0024-auspr TO qualification-profic_4.           "XCZK034654
    APPEND qualification.
  ENDLOOP.
  IF sy-subrc NE 0.                                         "4.6C
    REFRESH qualification. CLEAR qualification.             "4.6C
  ENDIF.                                                    "4.6C

  REFRESH tab.
  CLEAR tab.


*Lesen der Infosubtypeigenschaften fur den IT4002.

  SELECT * FROM t591a WHERE infty EQ '4002'.
    tab-subty = t591a-subty.
    APPEND tab.
    CLEAR tab.
  ENDSELECT.

  ind = 0.

  REFRESH vacancy_assignment.                "WBIK
  CLEAR vacancy_assignment.                  "WBIK

*LOOP AT S_VACANCIES.                      "WBIK059034

  LOOP AT s_vacancies WHERE indic = 'X'.                    "WBIK059034
    ADD 1 TO ind.
    READ TABLE tab INDEX ind.
    IF sy-subrc NE 0.
      EXIT.
    ENDIF.
    CLEAR vacancy_assignment.
    vacancy_assignment-priority = tab-subty.
    vacancy_assignment-va_status = '1'.
    vacancy_assignment-vacancy = s_vacancies-objid.
    APPEND vacancy_assignment.
  ENDLOOP.


*Default-Werte aus den Merkmalen INTDF und INTDY.

  infty_0001-werks = int_defaults-werks.
  infty_0001-btrtl = int_defaults-btrtl.
  infty_0001-persg = int_defaults-persg.
  infty_0001-persk = int_defaults-persk.
  infty_0001-sachp = int_defaults-sachp.
  infty_4001-spapl = int_defaults-spapl.
  infty_4001-media = int_defaults-media.

  p0002-sprsl = sy-langu.

  CLEAR: text_1000_2, text_1000_1.

  MOVE-CORRESPONDING p0002 TO old_per.
  MOVE-CORRESPONDING p0006 TO old_adr.


*Flag additional_suppress is set in case of internet application;
*for internet application an additional suppress dialog is necessary
*when automatically generating an activity.
*flag is imported in PBO-Module INIT_D1000 of program SAPMPAP3.

  EXPORT additional_suppress TO MEMORY ID 'ADD_SUPP'.      "XDVN618851


*Mit dieser Methode kann ein Bewerber angelegt werden. Es finden alle
*Konsistenzprufungen statt, die auch bei einer Bewerberdatenerfassung
*innerhalb der R/3-Transaktionen durchgefuhrt werden. Es wird nur dann
*ein Bewerber angelegt, wenn alle Konsistenzprufungen erfolgreich
*abgeschlossen werden konnten. Die vom System vergebene Bewerbernummer
*sowie ein Returncode werden zuruckgegeben.
*Technisch wird die Tabelle PROPOSED-VALUES gefullt, wobei diese Daten
*mit dem Dialogbaustein RP_TRANSFER_APPLICANT weggeschrieben werden.
*Der BAPI-Returnparameter wird gesetzt und die Texte der System-
*variablen werden im Nachrichtentext eingefugt.

  CALL FUNCTION 'BAPI_APPLICANT_CREATE'
    EXPORTING
      ap_group            = int_defaults-persg
      ap_subgrp           = int_defaults-persk
      pers_area           = int_defaults-werks
      p_subarea           = int_defaults-btrtl
      personnel           = int_defaults-sachp
      foa_key             = p0002-anred
      f_name              = old_per-vorna
      l_name              = old_per-nachn
      birthname           = old_per-name2
      known_as            = old_per-rufnm
      ssn                 = p0002-perid
      b_date              = p0002-gbdat
      title               = p0002-titel
      2nd_title           = p0002-titl2
      ari_title           = p0002-namzu
      affix               = p0002-vorsw
      prefix_2            = p0002-vors2
      gender              = p0002-gesch
      birthplace          = old_per-gbort
      mar_stat            = p0002-famst
      initials            = p0002-inits
      nation              = p0002-natio
      langu               = sy-langu
      c_o                 = old_adr-name2
      street              = old_adr-stras
      2nd_add_ln          = old_adr-locat
      city                = old_adr-ort01
      region              = p0006-state
      district            = old_adr-ort02
      pcd_city            = p0006-pstlz
      cntry               = p0006-land1
      tel_no              = p0006-telnr
      advert              = advert                    "XCZ
      unsappgp            = int_defaults-spapl
      medium              = int_defaults-media
      employeenumber      = pernr                           "WBIK031606
      communication_type  = '0010'                          "WBIK031606
      e_mail              = p0105-usrid_long                "WBIK031606
    IMPORTING
      applicantnumber     = rpapp-aplno
      return              = bapi_rcode
    TABLES
      education           = education
      previous_employment = employer
      qualification       = qualification
      vacancy_assignment  = vacancy_assignment
    EXCEPTIONS
      OTHERS              = 0.
  IF bapi_rcode IS INITIAL.                                 "WBIK059033
    PERFORM save_orig_data USING rpapp-aplno.               "WBIK059033
    already_applicant = yes.                                "XDVN427098
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.