02-10-2009 9:03 AM
Hi,
some of the fileds in infotype 40 updating into cluster table PCL1 table. can you please help me how to update.
regards
nagendra
02-10-2009 9:09 AM
Hi Nagendra,
see the below sample code to update IT0040.
REPORT zhr_sample.
TABLES: rp50m,pcl1,pcl2.
INFOTYPES: 0040.
DATA return1 TYPE bapireturn1.
INCLUDE: rpc1tx00. "Definition Cluster TX
INCLUDE: rpppxd00. "Buffer-Definition (I)
DATA: BEGIN OF COMMON PART buffer.
INCLUDE: rpppxd10. "Buffer-Definition (II)
DATA: END OF COMMON PART buffer.
INCLUDE: rpppxm00. "Buffer-Subroutines
START-OF-SELECTION.
CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
EXPORTING
number = '40001'
IMPORTING
return = return1.
IF return1 IS INITIAL.
p0040-pernr = '40001'.
p0040-infty = '0040'.
p0040-subty = '03'.
p0040-begda = '20090101'.
p0040-endda = '20091231'.
p0040-leihg = '03'.
p0040-anzkl = '1'.
p0040-zeinh = '020'. "Pieces
p0040-lobnr = '123456'.
p0040-itxex = 'X'.
rp50m-text1 = 'Objects on Loan Infotype working'.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0040'
number = '40001'
validityend = '01012009'
validitybegin = '31122009'
record = p0040
operation = 'INS'
dialog_mode = '0'
IMPORTING
return = return1.
CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
EXPORTING
number = '40001'
IMPORTING
return = return1.
ENDIF.
PERFORM update_cluster.
*&---------------------------------------------------------------------*
*& Form update_cluster
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM update_cluster.
CLEAR tx-key.
MOVE-CORRESPONDING p0040 TO tx-key.
MOVE rp50m-text1 TO ptext-line.
APPEND ptext.
EXPORT text-version
ptext
TO DATABASE pcl1(tx) ID tx-key.
IF sy-subrc = 0.
WRITE: / 'Cluster TX was updated successfully'(001).
ENDIF.
ENDFORM.
Thanks
V.Nagaraju
02-10-2009 9:09 AM
02-10-2009 9:09 AM
Hi Nagendra,
see the below sample code to update IT0040.
REPORT zhr_sample.
TABLES: rp50m,pcl1,pcl2.
INFOTYPES: 0040.
DATA return1 TYPE bapireturn1.
INCLUDE: rpc1tx00. "Definition Cluster TX
INCLUDE: rpppxd00. "Buffer-Definition (I)
DATA: BEGIN OF COMMON PART buffer.
INCLUDE: rpppxd10. "Buffer-Definition (II)
DATA: END OF COMMON PART buffer.
INCLUDE: rpppxm00. "Buffer-Subroutines
START-OF-SELECTION.
CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
EXPORTING
number = '40001'
IMPORTING
return = return1.
IF return1 IS INITIAL.
p0040-pernr = '40001'.
p0040-infty = '0040'.
p0040-subty = '03'.
p0040-begda = '20090101'.
p0040-endda = '20091231'.
p0040-leihg = '03'.
p0040-anzkl = '1'.
p0040-zeinh = '020'. "Pieces
p0040-lobnr = '123456'.
p0040-itxex = 'X'.
rp50m-text1 = 'Objects on Loan Infotype working'.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0040'
number = '40001'
validityend = '01012009'
validitybegin = '31122009'
record = p0040
operation = 'INS'
dialog_mode = '0'
IMPORTING
return = return1.
CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
EXPORTING
number = '40001'
IMPORTING
return = return1.
ENDIF.
PERFORM update_cluster.
*&---------------------------------------------------------------------*
*& Form update_cluster
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM update_cluster.
CLEAR tx-key.
MOVE-CORRESPONDING p0040 TO tx-key.
MOVE rp50m-text1 TO ptext-line.
APPEND ptext.
EXPORT text-version
ptext
TO DATABASE pcl1(tx) ID tx-key.
IF sy-subrc = 0.
WRITE: / 'Cluster TX was updated successfully'(001).
ENDIF.
ENDFORM.
Thanks
V.Nagaraju
02-10-2009 9:10 AM
03-02-2009 12:12 PM
Hi Nagendra,
Please see the below code:
REPORT ZNR_IT0040.
TABLES: rp50m,pcl1,pcl2.
INFOTYPES: 0040.
DATA return1 TYPE bapireturn1.
data: ZPKEY type bapipakey.
data: mpkey type pskey.
data: it_text type HRPAD_TEXT_TAB,
wa_text type HRPAD_TEXT.
START-OF-SELECTION.
CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
EXPORTING
number = '99999900'
IMPORTING
return = return1.
IF return1 IS INITIAL.
p0040-pernr = '99999900'.
p0040-infty = '0040'.
p0040-subty = '03'.
p0040-begda = '20090201'.
p0040-endda = '99991231'.
p0040-leihg = '03'.
p0040-anzkl = '1'.
p0040-zeinh = '020'. "Pieces
p0040-lobnr = '123456'.
p0040-itxex = 'X'.
rp50m-text1 = 'Objects on Loan Infotype working'.
rp50m-text2 = 'comments on Loan Infotype working'.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0040'
number = '99999900'
validityend = '01022009'
validitybegin = '31129999'
record = p0040
operation = 'MOD'
dialog_mode = '0'
IMPORTING
return = return1
KEY = ZPKEY.
* TRY.
move rp50m-text1 to wa_text.
append wa_text to it_text.
move rp50m-text2 to wa_text.
append wa_text to it_text.
MOVE-CORRESPONDING zpkey to mpkey.
CALL METHOD cl_hrpa_text_cluster=>update
EXPORTING
tclas = 'A'
pskey = mpkey
histo = ' '
* uname = SY-UNAME
* aedtm = SY-DATUM
pgmid = ' '
text_tab = it_text
no_auth_check = ' '.
* CATCH cx_hrpa_missing_authorization .
* CATCH cx_hrpa_violated_assertion .
* ENDTRY.
CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
EXPORTING
number = '99999900'
IMPORTING
return = return1.
ENDIF.
PERFORM print_cluster.
*&---------------------------------------------------------------------*
*& Form PRINT_CLUSTER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form PRINT_CLUSTER .
*TRY.
clear it_text[].
clear wa_text.
CALL METHOD cl_hrpa_text_cluster=>read
EXPORTING
tclas = 'A'
pskey = mpkey
no_auth_check = ' '
IMPORTING
* histo =
* uname =
* aedtm =
* pgmid =
text_tab = it_text
.
* CATCH cx_hrpa_missing_authorization .
* CATCH cx_hrpa_violated_assertion .
*ENDTRY.
loop at it_text into wa_text.
write:/5 wa_text.
endloop.
endform. " PRINT_CLUSTER
04-18-2013 1:03 PM
Hi Vandrulla,
After I used your above code and I find that the PA30 is getting update but wrongly.
By your code I observed if I create first record in infotype 0040 i get p0040-itxex = 'Space' instead of p0040-itxex = 'X' and also no updation for the long text (text1).
When I update 2nd record in infotype 0040 i get p0040-itxex = 'X' but long text = 'text1' instead of text2
When I update 3rd record in infotype 0040 i get p0040-itxex = 'X' but long text = 'text2' instead of text3
Subsequently for all the records. So i resolved the Problem by little changes (FM) in your code.
FUNCTION Z_PA30_IT0040_TEXT_UPDATE
"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(EMPLOYEENUMBER) TYPE PERNR_D
*" VALUE(TIMEINTERVALLOW) TYPE BEGDA
*" VALUE(TIMEINTERVALHIGH) TYPE ENDDA
*" VALUE(LEIHG) TYPE LEIHG
*" VALUE(ANZKL) TYPE CHAR4
*" VALUE(ZEINH) TYPE PT_ZEINH
*" VALUE(LOBNR) TYPE LOBNR
*" VALUE(NOCOMMIT) TYPE BAPI_STAND-NO_COMMIT
*" EXPORTING
*" VALUE(RETURN) TYPE BAPIRETURN1
*" VALUE(O_EMPLOYEENO) TYPE PERNR_D
*" VALUE(O_SUBTYPE) TYPE SUBTY
*" VALUE(O_OBJECTID) TYPE OBJPS
*" VALUE(O_LOCKINDIC) TYPE SPRPS
*" VALUE(O_VALIDBEGIN) TYPE BEGDA
*" VALUE(O_VALIDEND) TYPE ENDDA
*" VALUE(O_RECORDNR) TYPE SEQNR
*" TABLES
*" TEKSTDATA STRUCTURE ZHR_RFC_TEKSTDATA
*"----------------------------------------------------------------------
DATA lv_text TYPE hrpad_text.
MOVE employeenumber TO p0040-pernr.
MOVE timeintervallow TO p0040-begda.
MOVE timeintervalhigh TO p0040-endda.
MOVE leihg TO p0040-leihg.
MOVE leihg TO p0040-subty.
MOVE anzkl TO p0040-anzkl.
MOVE zeinh TO p0040-zeinh.
MOVE lobnr TO p0040-lobnr.
IF NOT tekstdata[] IS INITIAL.
p0040-itxex = 'X'.
ENDIF.
* FM to Update the infotype
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0040'
number = employeenumber
objectid = o_objectid
lockindicator = o_lockindic
validityend = timeintervalhigh
validitybegin = timeintervallow
recordnumber = o_recordnr
record = p0040
operation = create
nocommit = nocommit
IMPORTING
return = return
key = familykey
EXCEPTIONS
OTHERS = 0.
IF return-type NA 'AE' AND p0040-itxex = 'X'.
COMMIT WORK AND WAIT.
ENDIF.
IF NOT p0040-itxex IS INITIAL.
p0040-pernr = familykey-employeeno.
p0040-subty = familykey-subtype.
p0040-objps = familykey-objectid.
p0040-sprps = familykey-lockindic.
p0040-endda = familykey-validend.
p0040-begda = familykey-validbegin.
p0040-seqnr = familykey-recordnr.
PERFORM create_text TABLES tekstdata USING p0040.
ENDIF.
* Updation of p0040-itxex so that the long text get updated
DATA: lv_itxex TYPE itxex.
IF NOT p0040-itxex IS INITIAL.
PERFORM read_attr USING p0040 CHANGING lv_itxex.
IF NOT lv_itxex IS INITIAL.
SELECT SINGLE * FROM pa0040
INTO CORRESPONDING FIELDS OF p0040
WHERE pernr = familykey-employeeno
AND subty = familykey-subtype
AND objps = familykey-objectid
AND sprps = familykey-lockindic
AND endda = familykey-validend
AND begda = familykey-validbegin
AND seqnr = familykey-recordnr.
IF sy-subrc = 0.
UPDATE pa0040 SET itxex = 'X'
WHERE pernr = familykey-employeeno
AND subty = familykey-subtype
AND objps = familykey-objectid
AND sprps = familykey-lockindic
AND endda = familykey-validend
AND begda = familykey-validbegin
AND seqnr = familykey-recordnr.
ENDIF.
ENDIF.
ENDIF.
*&---------------------------------------------------------------------*
*& Form create_text
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TEKSTDATA text
* -->P_P0035 text
*----------------------------------------------------------------------*
FORM create_text TABLES p_tekstdata STRUCTURE zhr_rfc_tekstdata
USING p_key STRUCTURE p0040.
DATA pskey LIKE pskey.
DATA text_tab TYPE hrpad_text_tab.
DATA w_text TYPE hrpad_text.
CLEAR w_text.
REFRESH text_tab.
LOOP AT p_tekstdata INTO w_text.
APPEND w_text TO text_tab.
ENDLOOP.
pskey-pernr = p_key-pernr.
pskey-infty = '0040'.
pskey-subty = p_key-subty.
pskey-objps = p_key-objps.
pskey-sprps = p_key-sprps.
pskey-endda = p_key-endda.
pskey-begda = p_key-begda.
pskey-seqnr = p_key-seqnr.
* metoden update er statisk derfor =>
CALL METHOD cl_hrpa_text_cluster=>update
EXPORTING
tclas = 'A'
pskey = pskey
histo = ''
pgmid = 'SAPFP50P'
text_tab = text_tab
no_auth_check = ''.
ENDFORM. " create_text
*&---------------------------------------------------------------------*
*& Form READ_ATTR
*&---------------------------------------------------------------------*
* -->P_P0040 text
* <--P_LV_ITXEX text
*----------------------------------------------------------------------*
FORM read_attr USING p_p0040 STRUCTURE p0040
CHANGING cv_itxex TYPE itxex .
DATA pskey LIKE pskey.
pskey-pernr = p_p0040-pernr.
pskey-infty = '0040'.
pskey-subty = p_p0040-subty.
pskey-objps = p_p0040-objps.
pskey-sprps = p_p0040-sprps.
pskey-endda = p_p0040-endda.
pskey-begda = p_p0040-begda.
pskey-seqnr = p_p0040-seqnr.
CALL METHOD cl_hrpa_text_cluster=>read_attributes
EXPORTING
tclas = 'A'
pskey = pskey
no_auth_check = ''
IMPORTING
itxex = cv_itxex.
ENDFORM. " READ_ATTR
05-02-2014 3:54 PM
Sorry for reopening the topic.
I have the same requirement, in fact HR_INFOTYPE_OPERATION seems to delete the ITXEX flag that you can pass to it. When my operation is INS e.g. (inserting the record), the record is inserted, but the ITXEX flag is initial as in your case.
Unfortunately, I can't afford to call a commit work in that place, nor direct updates to the database. Is there any other way how to force SAP not changing the ITXEX attribute itself? Did you find any other (better) way?