Bdc for infotype 581
hi
I have to do bdc for infotype 581. The manual senario for this is after entering data in 581 and if i click save button it will save the data and it will go to infotype 8 screen. There it will populate the hra and value in wagetype and amount automatically. i will save that too.
but when i did this in bdc, after entering the data in 581 and clicking the save button it is not going to infotype 8 screen.
how can i store that hra in infotype 8 for that particular PERNR.
pls send the solutions for this
thanks in advance to all who will help
Hi,
When you are using BDC it will skip infotype 8. You should again upload infotype 8 for HRA.
Regards,
Ramu N.
Similar Messages
-
HR ABAP How to Write BDC For Infotype 0586
Hi Experts
Can Any One tell me how to write BDC for Infotype 0586 and also 585.
If we enter into the maintaining Screen, the lines in the Screen will dynamically changing depending on the values.
When I am doing recording , If I press page down after entering values in top lines, the lines are changing and the records are not updating Correctly.
I need to write BDC to Create Change.
Can any one please help me in this regard?
Thanks in Advance.
Regards
Avinash.http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
http://www.google.co.in/search?hl=en&q=SAPBDCtable+control&meta=
http://www.sap-basis-abap.com/abap/handling-table-control-in-bdc.htm
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
http://www.sap-img.com/abap/question-about-bdc-program.htm -
Hi,
I am trying to record a BDC for Infotype 0583 .
During manual creation , i am taken to the Infortpe 8 screen from the infotype 583 screen.
While recording through SHDB this is not happening. I am not taken to the Infotype 8 screen at all. The recording stops at the infotyp 0583 screen itself ,after I press the save buton.
Need some help guys.....
Regards,
Salishcheck this sample program
https://www.sdn.sap.com/irj/sdn/wiki?path=/pages/viewpage.action&pageid=13160
Regards
prabhu -
BDC for infotype 591??
HI
Can any1 send me BDC for infotype 591..had trouble with table control!!
Points will b suitably rewarded!!
Regards
GunjanHi Gunajn,
I am not connected to SAP now .. but this program should be fairly simple.. Use the function module GUI_UPLOAD or the other available OO methods to get your EXECL file into an internal table. loop at this table fill the p0591 record structure first say
p0591-pernr = itab-pernr.
p0591-infty = '0591'.
p0591-begda = itab-begda.
p0591-endda = itab-endda.
and so on fill up whatvevr fields you want, and then update infotype 0591 using std function module
call function 'HR_INFOTYPE_OPERATION'
exporting
infty = '0591'
number = itab-pernr
record = p0591
validityend = p0591-endda
validitybegin = p0591-begda
operation = 'INS'
tclas = 'A'
importing
return = rec_return.
the structure rec_return will help you trap errors if any. Start on these lines and paste your code if you still have issues. Your issue will sure be resolved on this forum.
Regards,
Suresh Datti.
Message was edited by: Suresh Datti -
Error in BDC for Infotype 0589
Hi friends,
I have developed a BDC program for Infotype 0589. After executing the program to upload data from file, I am getting error message: Field Q0589-ANZHL(7) input value is longer than screen field
Here I am adding my Sample code also.
REPORT ZTEST_0589.
PARAMETERS :
p_file TYPE rlgrap-filename. " Accepts File Name
*" Type declarations...................................................
TYPES :
BEGIN OF type_s_it0589,
pernr TYPE rp50g-pernr, " Personnel Number
inftyp TYPE rp50g-choic, " Infotype
begda TYPE p0589-begda, " Begin Date
endda TYPE p0589-endda, " End Date
lga01 TYPE q0589-lgart,
betrg01 TYPE q0589-betrg,
anzhl01 TYPE q0589-anzhl,
lga02 TYPE q0589-lgart,
betrg02 TYPE q0589-betrg,
anzhl02 TYPE q0589-anzhl,
lga03 TYPE q0589-lgart,
betrg03 TYPE q0589-betrg,
anzhl03 TYPE q0589-anzhl,
lga04 TYPE q0589-lgart,
betrg04 TYPE q0589-betrg,
anzhl04 TYPE q0589-anzhl,
lga05 TYPE q0589-lgart,
betrg05 TYPE q0589-betrg,
anzhl05 TYPE q0589-anzhl,
lga06 TYPE q0589-lgart,
betrg06 TYPE q0589-betrg,
anzhl06 TYPE q0589-anzhl,
lga07 TYPE q0589-lgart,
betrg07 TYPE q0589-betrg,
anzhl07 TYPE q0589-anzhl,
lga08 TYPE q0589-lgart,
betrg08 TYPE q0589-betrg,
anzhl08 TYPE q0589-anzhl,
END OF type_s_it0589.
Work variables
DATA:
w_file TYPE string, " File Name
w_betrg(50) TYPE c, " Proposed Contribution
w_anzhl(50) TYPE c, " Actual Contribution
w_count(2) TYPE n, " Counter
w_year(4) TYPE n, " Year
w_month(2) TYPE n, " Month
w_day(2) TYPE n, " Day
w_date(10) TYPE c, " Date
w_wage(50) TYPE c, " wage
w_waget(50) TYPE c, " wage type
w_curr(12) TYPE c, " Currency
w_tabrows LIKE sy-srows VALUE 7, " Table Control rows
w_update TYPE i, " Number of Updated Records
w_failed TYPE i, " Number of Failed Records
w_0589_lines TYPE i, " Number of Records in File
w_text TYPE string. " CheckBox for considering
" Actual Contributions
Structure to hold File Data *
DATA :
fs_it0589 TYPE type_s_it0589.
Structure to hold Batch input: New table field structure *
DATA :
fs_bdcdata TYPE bdcdata.
Structure to hold Messages in the SAP System *
DATA :
fs_messages TYPE bdcmsgcoll.
Structure to hold Personnel Number, Message Type & Message Text *
DATA:
BEGIN OF fs_log,
pernr TYPE rp50g-pernr,
msgtxt(200) TYPE c,
msgtyp TYPE c,
END OF fs_log.
Structure to hold Parameter string for runtime of CALL TRANSACTION *
DATA :
fs_opt TYPE ctu_params.
Internal Table to hold File Data *
DATA :
t_it0589 LIKE
STANDARD TABLE
OF fs_it0589.
Internal Table to hold Batch input: New table field structure *
DATA :
t_bdcdata TYPE
STANDARD TABLE
OF bdcdata.
Internal Table to hold Messages in the SAP System *
DATA:
t_messages TYPE TABLE OF bdcmsgcoll.
Internal Table to hold Personnel Number, Message Type & Message Text*
DATA:
t_log LIKE
STANDARD TABLE
OF fs_log.
FORM validate .
IF p_file IS INITIAL.
MESSAGE e005(zvalid).
ENDIF. " IF P_FILE IS INITIAL.
MOVE p_file TO w_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = w_file
filetype = 'ASC'
has_field_separator = 'X'
dat_mode = 'X'
TABLES
data_tab = t_it0589
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
IF t_it0589 IS INITIAL.
MESSAGE e006(zvalid).
ENDIF. " IF T_IT0589 IS INITIAL
ENDFORM. " FORM VALIDATE
FORM f4_help .
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
ENDFORM. " FORM F4_HELP
*& Form FILL_BDCDATA
FORM fill_bdcdata .
DESCRIBE TABLE t_it0589 LINES w_0589_lines.
LOOP AT t_it0589 INTO fs_it0589.
REFRESH t_bdcdata.
REFRESH t_messages.
PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.
PERFORM bdc_field USING 'RP50G-PERNR'
fs_it0589-pernr.
w_year = fs_it0589-begda+0(4).
w_month = fs_it0589-begda+4(2).
w_day = fs_it0589-begda+6(2).
CONCATENATE w_day w_month w_year INTO w_date
SEPARATED BY '.'.
PERFORM bdc_field USING 'RP50G-BEGDA'
w_date.
w_year = fs_it0589-endda+0(4).
w_month = fs_it0589-endda+4(2).
w_day = fs_it0589-endda+6(2).
CONCATENATE w_day w_month w_year INTO w_date
SEPARATED BY '.'.
PERFORM bdc_field USING 'RP50G-ENDDA'
w_date.
PERFORM bdc_field USING 'RP50G-CHOIC'
fs_it0589-inftyp.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'=INS'.
PERFORM bdc_dynpro USING 'MP058900' '2000'.
1st Row...............................................................
ADD 1 TO w_count.
MOVE fs_it0589-lga01 TO w_wage.
PERFORM bdc_field USING 'Q0589-LGART(01)'
w_wage.
MOVE fs_it0589-betrg01 TO w_curr.
PERFORM bdc_field USING 'Q0589-BETRG(01)'
w_curr.
MOVE fs_it0589-anzhl01 TO w_curr.
PERFORM bdc_field USING 'Q0589-ANZHL(01)'
w_curr.
2nd Row...............................................................
3rd Row...............................................................
4th Row...............................................................
5th Row...............................................................
6th Row...............................................................
ADD 1 TO w_count.
IF w_count > w_tabrows .
w_count = 1.
PERFORM bdc_field USING 'BDC_OKCODE'
'P+' .
PERFORM bdc_dynpro USING 'MP058900' '2000'.
ENDIF. " IF W_COUNT > W_TABROWS
MOVE fs_it0589-lga06 TO w_curr.
CONCATENATE 'Q0589-LGART(' w_count ')' INTO w_wage.
PERFORM bdc_field USING w_wage
w_curr.
MOVE fs_it0589-betrg06 TO w_curr.
CONCATENATE 'Q0589-BETRG(' w_count ')' INTO w_betrg.
PERFORM bdc_field USING w_betrg
w_curr.
MOVE fs_it0589-anzhl06 TO w_curr.
CONCATENATE 'Q0589-ANZHL(' w_count ')' INTO w_anzhl.
PERFORM bdc_field USING w_anzhl
w_curr.
7th Row...............................................................
ADD 1 TO w_count.
IF w_count > w_tabrows .
w_count = 1.
PERFORM bdc_field USING 'BDC_OKCODE'
'P+' .
PERFORM bdc_dynpro USING 'MP058900' '2000'.
ENDIF. " IF W_COUNT > W_TABROWS
MOVE fs_it0589-lga07 TO w_curr.
CONCATENATE 'Q0589-LGART(' w_count ')' INTO w_wage.
PERFORM bdc_field USING w_wage
w_curr.
MOVE fs_it0589-betrg07 TO w_curr.
CONCATENATE 'Q0589-BETRG(' w_count ')' INTO w_betrg.
PERFORM bdc_field USING w_betrg
w_curr.
MOVE fs_it0589-anzhl07 TO w_curr.
CONCATENATE 'Q0589-ANZHL(' w_count ')' INTO w_anzhl.
PERFORM bdc_field USING w_anzhl
w_curr.
*- -- Same upto 15 rows.......
Save..................................................................
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
Back..................................................................
PERFORM bdc_dynpro USING 'MP058900' '2000'.
PERFORM bdc_field USING 'BDC_OKCODE'
'/EBCK'.
w_count = 0.
CALL TRANSACTION 'PA30' USING t_bdcdata
OPTIONS FROM fs_opt
MESSAGES INTO t_messages.
LOOP AT t_messages INTO fs_messages.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = fs_messages-msgid
lang = sy-langu
no = fs_messages-msgnr
v1 = fs_messages-msgv1
v2 = fs_messages-msgv2
v3 = fs_messages-msgv3
v4 = fs_messages-msgv4
IMPORTING
msg = fs_log-msgtxt
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. " IF SY-SUBRC NE 0
MOVE fs_it0589-pernr TO fs_log-pernr.
MOVE fs_messages-msgtyp TO fs_log-msgtyp.
APPEND fs_log TO t_log.
CLEAR fs_log.
IF fs_messages-msgtyp EQ 'S'
AND fs_messages-msgnr EQ '102'.
ADD 1 TO w_update.
ELSEIF fs_messages-msgtyp EQ 'S'
AND fs_messages-msgnr EQ '015'
OR fs_messages-msgtyp EQ 'E'.
ADD 1 TO w_failed.
ENDIF. " IF FS_MESSAGES-MSGTYP EQ 'S'
ENDLOOP. " LOOP AT T_MESSAGES
ENDLOOP. " LOOP AT T_IT0585
WRITE :/ 'Number of Records Fetched from file'(001),
50 w_0589_lines COLOR 1,
/ 'Number of Records Updated into the database'(002),
50 w_update COLOR 1,
/ 'Number of Records Failed to update into database'(003),
50 w_failed COLOR 6 .
SKIP 3.
WRITE :/ 'Detailed Log.....'(004).
SKIP 1.
LOOP AT t_log INTO fs_log.
AT NEW pernr.
WRITE :/ fs_log-pernr COLOR 1.
ENDAT. " AT NEW PERNR
IF fs_log-msgtyp = 'E'.
WRITE :15 fs_log-msgtxt COLOR 6 INVERSE ON.
ELSE.
WRITE :15 fs_log-msgtxt.
ENDIF. " IF FS_LOG-MSGTYP = 'E'
ENDLOOP. " LOOP AT T_LOG INTO FS_LOG
ENDFORM. " FORM FILL_BDCDATA
*& Form BDC_DYNPRO
This subroutine starts new screen *
There are no interface parameters to be passed to this subroutine. *
FORM bdc_dynpro USING program dynpro.
CLEAR fs_bdcdata.
fs_bdcdata-program = program.
fs_bdcdata-dynpro = dynpro.
fs_bdcdata-dynbegin = 'X'.
APPEND fs_bdcdata TO t_bdcdata.
ENDFORM. " FORM BDC_DYNPRO
*& Form BDC_FIELD
This subroutine inserts field *
There are no interface parameters to be passed to this subroutine. *
FORM bdc_field USING fnam fval.
CLEAR fs_bdcdata.
fs_bdcdata-fnam = fnam.
fs_bdcdata-fval = fval.
APPEND fs_bdcdata TO t_bdcdata.
ENDFORM. " FORM BDC_FIELD
Thanks,
Ziad khanHi Amit,
Thaks for reply. Amit, I am new to ABAP-HR so i dont know how to use FM "HR_MAINTAIN_MASTERDATA".
Can u please explain in detail.
Thanks
Ziad -
Hi Gurus!
Was wondering when is it obligatory to use BDC instead of function module to upload data?
Aint it so that this function module HR_INFOTYPE_OPERATION works fine even when the infotype is enhanced?
Reward points for good answers.
RegardsHi,
Sometimes BDC is required instead of FM 'HR_INFOTYPE_OPERATION', cause the infotype might be using some other include infotypes or strucutres for maintaining the data. for examples :
1. Infotype 25(Appraisals), the data is stored in some other tables hence the above FM will not work.
2.Infotype 0045(Loans) stored the payment details in IT 78 which cannot be update simultaneoulsy along with IT 0045,you need to call above FM twice for both IT 45 & IT 78, incase any one gives error you need to again call the same FM for deletion.
In all case where data is stored in different table rather than corresponing infotype table,I doubt the above FM will work. Hope this justifies.
Regards,
Dadarao. -
hi ,
here we r suffering with the problem that when we want to enter data for NON-METRO FOR City Category it always shows fill all required fileds.
in V_T7INR9 view is there any need to maintain value for NON-METRO .
i will be very greateful plz help in it.
thnx in advance.Check out this code:
*& Report ZTEST3
REPORT ztest3.
TYPES:
BEGIN OF x_employee,
id TYPE n LENGTH 10,
name TYPE c LENGTH 20,
group TYPE c LENGTH 4,
END OF x_employee,
BEGIN OF x_emp_sal,
id TYPE n LENGTH 10,
salary TYPE p LENGTH 16 DECIMALS 2,
END OF x_emp_sal,
BEGIN OF x_final,
group TYPE c LENGTH 4,
id TYPE n LENGTH 10,
name TYPE c LENGTH 20,
salary TYPE p LENGTH 16 DECIMALS 2,
END OF x_final.
DATA:
i_employee TYPE STANDARD TABLE OF x_employee INITIAL SIZE 0,
i_final TYPE STANDARD TABLE OF x_final INITIAL SIZE 0,
i_salary TYPE STANDARD TABLE OF x_emp_sal INITIAL SIZE 0,
wa_employee TYPE x_employee,
wa_salary TYPE x_emp_sal,
wa_final TYPE x_final,
wa_final_temp TYPE x_final.
DEFINE append_employee.
wa_employee-id = &1.
wa_employee-name = &2.
wa_employee-group = &3.
append wa_employee to i_employee.
END-OF-DEFINITION.
DEFINE append_salary.
wa_salary-id = &1.
wa_salary-salary = &2.
append wa_salary to i_salary.
END-OF-DEFINITION.
append_employee:
1 'John' 'ENG',
2 'Mary' 'ENG',
3 'Pooja' 'IT',
4 'Payal' 'IT',
5 'Sourav' 'IT'.
append_salary:
1 '111.00',
2 '1111.00',
3 '11111.00',
4 '111111.00',
5 '1111111.00'.
LOOP AT i_employee INTO wa_employee.
READ TABLE i_salary INTO wa_salary
WITH KEY id = wa_employee-id.
IF sy-subrc = 0.
wa_final-id = wa_employee-id.
wa_final-name = wa_employee-name.
wa_final-group = wa_employee-group.
wa_final-salary = wa_salary-salary.
APPEND wa_final TO i_final.
ENDIF.
ENDLOOP.
SORT i_final BY group.
LOOP AT i_final INTO wa_final_temp.
wa_final = wa_final_temp.
AT END OF group.
SUM.
WRITE: /1 wa_final_temp-group, 5 wa_final_temp-salary.
ENDAT.
ENDLOOP.
output will be:
ENG 1.222,00
IT 1.233.333,00
Edited by: Sourav Bhaduri on Sep 24, 2008 1:44 AM -
Can any body tell me how to upload data for infotype 2011
hi gurus,
please tell me hw to create the bdc for infotype 2011.Go to SHDB and record the Tcode PA30 with Infotype 2011.
~BiSu -
Error while updating HRA in infotype 581 for the employees.
Hi,
System is showing an error while updating HRA in infotype 581 for the employees.
The error is No Automatic updation for IT0008. Allowance Grouping not found.
What is this error. Please advice what to do in this case.Hi Deepthi,
Check Table V_T7INA5,V_T7INA1,V_T7INA3 and V_T7INA9 also.
Check it,
Regards,
Vinod.
Edited by: vinod rao on Jul 30, 2008 1:23 PM -
BDC for Local FIle as Long Text
Dear All,
Developing a BDC which upload Individual Files as Text for Infotype 1002 Description so please anybody tell me how to add Local File.
I have done the Recording but in that how to add Text which is taken from Local Text File.
Thanks in advance.
Regards
MangeshHI Mangesa,
Use FM GUI_UPLOAD.
This is use to upload data from text file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = fname
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = '#'
tables
data_tab = i_tab
Regards,
Tutun -
Hr...bdc for pa40-salary increment
HI FRIENDS..
M NOT ABLE TO FETCH VALUES FOR TABLE CONTORL IN PA40 T.CODE FOR SALARY INCREMENT..
ACT D PROBLEM IS..
THE OLD SALARY SRTUCTURE IS DIFFERENG FROM CURRENT SALARY STRUCTURE IN EXCEL SHEET..
DOES ANY1 HAVE THE BDC FOR SALARY INCREMENT ..?
PLS HELP..
PTS REWRDED FOR SURE..Hi,
We never write BDC for PA40.
Write it for PA30.
Goto SHDB tcode and record for the required infotype.
Or you can also use any of the following FM instead of BDc.
HR_INFOTYPE_OPERATION
HR_MAINTAIN_MASTERDATA.
Refer
https://forums.sdn.sap.com/click.jspa?searchID=4208189&messageID=3188548
https://forums.sdn.sap.com/click.jspa?searchID=4208189&messageID=1552901
Regards -
BDC for PA30 action hire is not creating entry in IT 1001
Hello All,
I created a BDC for to create hire action in system to create some dummy data, but its not creating entry in infotype 1001 for relation between person (P) and position (S). If i create entry in PA30 it create ebtry, if i try BDC in Dialog mode even then its not creating it.
I read a lot about Dynamic action in this kind of issue but i seen table T588Z but there is no any insert dynamic action for IT 1001.
Can anybody throw some light on the cause of the same.
i tried to create same data with FM HR_MIANTAIN_MASTERDATA but i have to drop that idea becasue it was not able to crate record with empty PERNR field. if your answer is use this FM then please provide some working code as i searched a lot on the same issue but no any concrete proof on the same.
appreciate any reply.
ManiHi,
Are you getting any error?
If not i think you have to lock the employee before creating an entry to the IT 1001 using FM
'BAPI_EMPLOYEE_ENQUEUE'
and create an entry to IT 1001 using BDC or HR_MIANTAIN_MASTERDATA
and unlock an employee by using FM
'BAPI_EMPLOYEE_DEQUEUE'
Regards
Krishna -
BDC on Infotype 1 , 2 and 8
Hi
Im new to ABAP HR and im required to do BDC on Infotype 1,2,8. Can anyone send me samples that i can proceed ?
Thanks and Regards
Swarna ArunachalamIt is not recommeneded to perform a BDC on infotypes as dynamic screen sequences are involved in it. If the data is not too huge one can use the function module <b>HR_INFOTYPE_OPERATION</b> for uploading data into infotypes, please search the forum for the function module specified, u can find lots of posts on the same.
-
can any one send any program for uploading data through bapi for any infotype. so that i can understand bapi for infotypes.
hi
just create a message class and text according to the code as follows (copy and paste in se 38)
REPORT ZCHR007_01 NO STANDARD PAGE HEADING MESSAGE-ID ZHR LINE-COUNT 65(8) LINE-SIZE 180.
TABLES : PA0003, P0000,P0006,T005S,T005,T591A. " TABLES REQUIRED
*INTERNAL TABLE AND WORK AREA WITH STRUCTURE ON BASIS FLAT FILE DATA.
TYPES : BEGIN OF x_flat_infotype, "Flat file structure
Screen data
PERNR TYPE PERSNO, "Personal Number
BEGDA TYPE BEGDA, "Begin Date
ENDDA TYPE ENDDA, "End Date
ANSSA TYPE ANSSA, "Address Record Type
STRAS TYPE PAD_STRAS, "House number and street
LOCAT TYPE PAD_LOCAT, "2nd Address Line
PSTLZ TYPE PSTLZ_HR, "Postal Code
ORT01 TYPE PAD_ORT01, "City
ORT02 TYPE PAD_ORT02, "District
STATE TYPE REGIO, "State
land1 TYPE land1, "Country
telnr TYPE telnr, "Telephone Number
wkwng TYPE wkwng, "Company Housing
END OF x_flat_infotype.
TYPES : BEGIN OF x_valid.
INCLUDE TYPE x_flat_infotype. "structure for valid data
TYPES : END OF x_valid.
TYPES : BEGIN OF x_invalid.
INCLUDE TYPE x_flat_infotype. "structure for invalid data
TYPES : error TYPE string, "string to hold error field details
END OF x_invalid,
BEGIN OF x_pernr, "STRUCTURE DECLARATION FOR Personal No
pernr TYPE persno,
END OF x_pernr,
BEGIN OF x_state, "STRUCTURE DECLARATION FOR Region
land1 type land1,
state TYPE regio,
END OF x_state,
BEGIN OF x_land1, "STRUCTURE DECLARATION FOR Country
land1 TYPE land1,
END OF x_land1.
DATA : t_infotype TYPE STANDARD TABLE OF x_flat_infotype INITIAL SIZE 0, "internal table to hold data
t_valid TYPE STANDARD TABLE OF x_valid INITIAL SIZE 0, "internal table to hold valid data
t_invalid TYPE STANDARD TABLE OF x_invalid INITIAL SIZE 0, "internal table to hold invalid data
t_v_final TYPE STANDARD TABLE OF x_valid INITIAL SIZE 0, "internal table to hold valid data
DECLARE IT_BDCDATA INTERNAL TABLE BASED ON BDCDATA STRUCTURE
t_bdcdata TYPE STANDARD TABLE OF bdcdata INITIAL SIZE 0, "internal table to hold BDC data
Work area for the above internal tables
wa_infotype TYPE x_flat_infotype, "work area to hold data
wa_valid TYPE x_valid, "work area to hold valid data
wa_invalid TYPE x_invalid, "work area to hold invalid data
wa_v_final TYPE x_valid, "work area to hold valid data
wa_bdcdata TYPE bdcdata, "work area to hold BDC data
g_file TYPE string, "Variable to hold file name entered by user
g_errfile TYPE string. "Variable to hold file name entered by user
MAINTAINING A BLOCK WITH FLAT FILE AS INPUT
PARAMETER : p_file TYPE fc03tab-pl00_file OBLIGATORY. "variable to hold flat file name during runtime
INITIALIZATION.
PERFORM sub_refreshing_inttables. "Subroutine for refreshing all internal tables
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
PERFORM sub_get_file USING p_file. "TO SELECT A FILE USING F4 KEY.
START-OF-SELECTION.
PERFORM sub_upload_file. " UPLOADING FILE WITH DATA
PERFORM sub_file_validations. " flat file validations
IF NOT t_valid[] IS INITIAL. "checking for valid data
PERFORM sub_data_updatation. "updation of data depending on selected method
ENDIF.
IF NOT t_invalid[] IS INITIAL.
PERFORM sub_download_error_file. "TO DOWNLOAD ERRROR FILE
ENDIF.
Perform sub_details. "Subroutine for loading details
END-OF-SELECTION.
PERFORM sub_free. "TO Free Memory
*& Form sub_refreshing_inttables
"Subroutine for refreshing all internal tables
FORM sub_refreshing_inttables . "REFRESH ALL INTERNAL TABLES
REFRESH : t_infotype,t_valid,t_invalid,t_bdcdata.
ENDFORM. " sub_refreshing_inttables
*& Form sub_get_file
Subroutine for selection a file during runtime
-->P_P_FILE Input File
FORM sub_get_file USING p_p_file.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
field_name = 'PA_FILE'
CHANGING
file_name = p_p_file.
ENDFORM. " sub_get_file
*& Form sub_upload_file
Subroutine for uploading data into internal table
FORM sub_upload_file.
CONSTANTS : lc_ftype TYPE char10 VALUE 'ASC',
lc_fsepe TYPE char01 VALUE 'X'.
g_file = p_file. "STORE FILENAME IN VARIABLE(g_FILE)
IF p_file IS INITIAL. " if file is not selected
MESSAGE i002.
LEAVE LIST-PROCESSING.
ELSE.
CALL FUNCTION 'GUI_UPLOAD' "CALLLING FUNCTION TO UPLOAD THE FILE DATA
EXPORTING
filename = g_file
filetype = lc_ftype
has_field_separator = lc_fsepe
TABLES
data_tab = t_infotype
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17
IF sy-subrc <> 0. "message to display is file is not selected
MESSAGE i001.
LEAVE LIST-PROCESSING.
ENDIF.
ENDIF.
ENDFORM. " sub_upload_file
*& Form sub_file_validations
Subroutine for validating required fields in flat file
FORM sub_file_validations .
CONSTANTS: lc_anssa1 TYPE char04 VALUE '1', "Constant address type
lc_anssa2 TYPE char04 VALUE '2', "Constant address type
lc_anssa3 TYPE char04 VALUE '3', "Constant address type
lc_anssa4 TYPE char04 VALUE '4', "Constant address type
lc_wkwng1 TYPE char01 VALUE '1', "Constant Company Housing
lc_wkwng2 TYPE char01 VALUE '2'. "Constant Company Housing
DATA : t_pernr TYPE STANDARD TABLE OF x_pernr INITIAL SIZE 0, "INTERNAL TABLE FOR Personal No data
t_state TYPE STANDARD TABLE OF x_state INITIAL SIZE 0, "INTERNAL TABLE FOR Region data
t_land1 TYPE STANDARD TABLE OF x_land1 INITIAL SIZE 0. "INTERNAL TABLE FOR Country data
IF t_infotype IS NOT INITIAL.
validate Personal No
SELECT pernr FROM pa0003 INTO TABLE t_pernr " Extracting Personal No Data FROM TO VALIDATE THE FIELD
FOR ALL ENTRIES IN t_infotype WHERE pernr = t_infotype-pernr.
IF sy-subrc = 0.
SORT t_pernr BY pernr.
ENDIF.
validate Region
SELECT land1 bland FROM t005s INTO TABLE t_state . " Extracting Region DATA FROM TO VALIDATE THE FIELD
IF sy-subrc = 0.
SORT t_state BY land1 state.
ENDIF.
validate Country
SELECT land1 FROM t005 INTO TABLE t_land1 . " Extracting country DATA FROM TO VALIDATE THE FIELD
IF sy-subrc = 0.
SORT t_land1 BY land1 .
ENDIF.
ELSE.
MESSAGE i004.
LEAVE LIST-PROCESSING.
ENDIF.
CLEAR wa_infotype. "clearing data from work area of infotype internal table
LOOP AT t_infotype INTO wa_infotype.
PERFORM sub_valid_nonvalidatefield.
PERFORM sub_startdate_validaion. "Subroutine to validate start date field
PERFORM sub_enddate_validaion. "Subroutine to validate end date field
IF wa_valid-begda GE wa_valid-endda. "If start date is less than or equal to end date
wa_invalid-begda = wa_infotype-begda. "moving start date to invalid workarea of start date
wa_invalid-endda = wa_infotype-endda. "moving start date to invalid workarea of start date
CONCATENATE text-032 wa_invalid-begda
wa_invalid-error INTO wa_invalid-error SEPARATED BY space .
ENDIF.
validate field Address Type of flat file with field in check table
IF wa_infotype-anssa = lc_anssa1 OR wa_infotype-anssa = lc_anssa2
OR wa_infotype-anssa = lc_anssa3 OR wa_infotype-anssa = lc_anssa4 .
wa_valid-anssa = wa_infotype-anssa. "moving Address type from internal table to valid internal table
ELSE.
wa_invalid-anssa = wa_infotype-anssa. "moving Address type from internal table to invalid internal table
CONCATENATE text-033 wa_invalid-anssa
wa_invalid-error INTO wa_invalid-error SEPARATED BY space .
ENDIF.
validate field Personal No of flat file with field in check table
READ TABLE t_pernr WITH KEY pernr = wa_infotype-pernr
BINARY SEARCH
TRANSPORTING NO FIELDS .
IF sy-subrc = 0. "checking for validation of the Personal No
wa_valid-pernr = wa_infotype-pernr. "moving Personal No from internal table to valid internal table
ELSE.
wa_invalid-pernr = wa_infotype-pernr. "moving Personal No from internal table to invalid internal table
CONCATENATE text-030 wa_invalid-pernr
wa_invalid-error INTO wa_invalid-error SEPARATED BY space .
ENDIF.
validate field State of flat file with field in check table
READ TABLE t_state WITH KEY land1 = wa_infotype-land1 STATE = wa_infotype-state
BINARY SEARCH
TRANSPORTING NO FIELDS .
IF sy-subrc = 0. "checking for validation of the State
wa_valid-state = wa_infotype-state. "moving State from internal table to valid internal table
ELSE.
wa_invalid-state = wa_infotype-state. "moving State from internal table to invalid internal table
CONCATENATE text-010 wa_invalid-state
wa_invalid-error INTO wa_invalid-error SEPARATED BY space .
ENDIF.
validate field Country of flat file with field in check table
READ TABLE t_land1 WITH KEY land1 = wa_infotype-land1
BINARY SEARCH
TRANSPORTING NO FIELDS .
IF sy-subrc = 0. "checking for validation of the Country
wa_valid-land1 = wa_infotype-land1. "moving Country from internal table to valid internal table
ELSE.
wa_invalid-land1 = wa_infotype-land1. "moving Country from internal table to invalid internal table
CONCATENATE text-011 wa_invalid-land1
wa_invalid-error INTO wa_invalid-error SEPARATED BY space .
ENDIF.
IF wa_infotype-wkwng = lc_wkwng1 OR wa_infotype-wkwng = lc_wkwng2 .
wa_valid-wkwng = wa_infotype-wkwng. "moving Company Housing from internal table to valid internal table
ELSE.
wa_invalid-wkwng = wa_infotype-wkwng. "moving Company Housing from internal table to invalid internal table
CONCATENATE text-034 wa_invalid-wkwng
wa_invalid-error INTO wa_invalid-error SEPARATED BY space .
ENDIF.
For Invalid data
IF wa_invalid IS NOT INITIAL. "checking all fields data for invalid entries
CONCATENATE text-012
wa_invalid-error INTO wa_invalid-error.
PERFORM sub_invalid_nonvalidatefield.
IF wa_invalid-pernr IS INITIAL.
wa_invalid-pernr = wa_valid-pernr. "Personal No
ENDIF.
IF wa_invalid-begda IS INITIAL.
wa_invalid-begda = wa_valid-begda. "Begin date
ENDIF.
IF wa_invalid-endda IS INITIAL.
wa_invalid-endda = wa_valid-endda. "End Date
ENDIF.
IF wa_invalid-anssa IS INITIAL.
wa_invalid-anssa = wa_valid-anssa. "Address Type
ENDIF.
IF wa_invalid-state IS INITIAL.
wa_invalid-state = wa_valid-state. "State
ENDIF.
IF wa_invalid-land1 IS INITIAL.
wa_invalid-land1 = wa_valid-land1. "Country
ENDIF.
APPEND wa_invalid TO t_invalid. "Appending data to invalid internal table
ELSE.
APPEND wa_valid TO t_valid. "Appending data to valid internal table
ENDIF.
CLEAR wa_valid.
CLEAR wa_invalid.
ENDLOOP.
ENDFORM. " sub_file_validations
*& Form sub_valid_nonvalidatefield
Subroutine for updating non-validated fields into valid work area
FORM sub_valid_nonvalidatefield .
wa_valid-stras = wa_infotype-stras. "moving Str&Hou from internal table to valid internal table
wa_valid-locat = wa_infotype-locat. "moving 2nd Address line from internal table to valid internal table
wa_valid-pstlz = wa_infotype-pstlz. "moving Postal Code from internal table to valid internal table
wa_valid-ort01 = wa_infotype-ort01. "moving City from internal table to valid internal table
wa_valid-ort02 = wa_infotype-ort02. "moving District from internal table to valid internal table
wa_valid-telnr = wa_infotype-telnr. "moving Telephone No from internal table to valid internal table
ENDFORM. " sub_valid_nonvalidatefield
*& Form sub_startdate_validaion
"Subroutine to validate start date field
FORM sub_startdate_validaion .
*This Funciton module is used for Conversion of date, ie External to
*internal date (like screen conversion)
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = wa_infotype-begda "External date or date given in flat file
IMPORTING
date_internal = wa_valid-begda "Date converted to internal format for conversion
EXCEPTIONS
date_external_is_invalid = 1
OTHERS = 2.
IF sy-subrc <> 0. "If conversion of date fails
wa_invalid-begda = wa_infotype-begda. "moving date from flat file work area to inavlid work area
CONCATENATE text-035 wa_invalid-begda
wa_invalid-error INTO wa_invalid-error SEPARATED BY space. " Adding start date error to error field of invalid internal table
ENDIF.
ENDFORM. " sub_startdate_validaion
*& Form sub_enddate_validaion
"Subroutine to validate end date field
FORM sub_enddate_validaion .
*This Funciton module is used for Conversion of date, ie External to
*internal date (like screen conversion)
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = wa_infotype-endda "External date or date given in flat file
IMPORTING
date_internal = wa_valid-endda "Date converted to internal format for conversion
EXCEPTIONS
date_external_is_invalid = 1
OTHERS = 2.
IF sy-subrc <> 0. "If conversion of date fails
wa_invalid-endda = wa_infotype-endda. "moving date from flat file work area to inavlid work area
CONCATENATE text-036 wa_invalid-endda
wa_invalid-error INTO wa_invalid-error SEPARATED BY space. " Adding end date error to error field of invalid internal table
ENDIF.
ENDFORM. " sub_enddate_validaion
*& Form sub_invalid_nonvalidatefield
Subroutine for updating non-validated fields into invalid work area
FORM sub_invalid_nonvalidatefield .
wa_invalid-stras = wa_infotype-stras. "moving Str&Hou from internal table to invalid internal table
wa_invalid-locat = wa_infotype-locat. "moving 2nd Address line from internal table to invalid internal table
wa_invalid-pstlz = wa_infotype-pstlz. "moving Postal Code from internal table to invalid internal table
wa_invalid-ort01 = wa_infotype-ort01. "moving City from internal table to invalid internal table
wa_invalid-ort02 = wa_infotype-ort02. "moving District from internal table to invalid internal table
wa_invalid-telnr = wa_infotype-telnr. "moving Telephone No from internal table to invalid internal table
ENDFORM. " sub_invalid_nonvalidatefield
*& Form sub_data_updatation
Subroutine for updation of data depending on selected method
FORM sub_data_updatation .
DATA : wa_return_enque TYPE bapireturn1. "variable to store error values
clear wa_return_enque.
LOOP AT t_valid INTO wa_valid. "moving valid data to valid work area
PERFORM sub_bapi_employee_enqueue using wa_return_enque . "Subroutine to lock an employee
IF wa_return_enque-type NE 'E'.
PERFORM sub_bapi_addressempdk_create. "Subroutine to create employee address data
ENDIF.
ENDLOOP.
ENDFORM. " sub_data_updatation
*& Form sub_bapi_employee_enqueue
Subroutine to lock an employee
<--P_WA_RETURN_ENQUE wa_return_enque-type
FORM sub_bapi_employee_enqueue using p_wa_return_enque LIKE bapireturn1.
*This funciton module is used to lock an employee so that the records
*stored for this person cannot be accessed.
*When an employee is locked, only user who has set lock can access
*records for this employee. Other users are denied access.
CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
EXPORTING
number = wa_valid-pernr "Personal number
IMPORTING
return = p_wa_return_enque. "for error values returned
ENDFORM. " sub_bapi_employee_enqueue
*& Form sub_BAPI_ADDRESSEMPDK_CREATE
Subroutine to create employee address data
FORM sub_bapi_addressempdk_create.
DATA : wa_data_create TYPE bapireturn1. "variable to store error values
*This function module is used create a Address Data record (0006).
CALL FUNCTION 'BAPI_ADDRESSEMPDK_CREATE'
EXPORTING
employeenumber = wa_valid-pernr "Personal No
validitybegin = wa_valid-begda "Begin Date
validityend = wa_valid-endda "End Date
addresstype = wa_valid-anssa "Address type
streetandhouseno = wa_valid-stras "Street and house address
scndaddressline = wa_valid-locat "2nd address line
city = wa_valid-ort01 "City
district = wa_valid-ort02 "District
postalcodecity = wa_valid-pstlz "Postal Code
state = wa_valid-state "Region(State)
country = wa_valid-land1 "Country
company_apartment = wa_valid-wkwng "Company Housing
telephonenumber = wa_valid-telnr "Telephone No
IMPORTING
return = wa_data_create
employeenumber = wa_valid-pernr
subtype = wa_valid-anssa
validitybegin = wa_valid-begda
validityend = wa_valid-endda.
If error or abend message occurs while uploading data, then moving all the wa_valid fields to wa_invalid fields.
IF wa_data_create-type EQ 'E'
OR wa_data_create-type EQ 'A'.
PERFORM sub_bapi_employee_dequeue. "Subroutine to unlock an employee
wa_invalid-pernr = wa_valid-pernr . "Personal No
wa_invalid-begda = wa_valid-begda . "Begin Date
wa_invalid-endda = wa_valid-endda . "End Date
wa_invalid-anssa = wa_valid-anssa . "Address type
wa_invalid-stras = wa_valid-stras . "Street and house address
wa_invalid-locat = wa_valid-locat . "2nd address line
wa_invalid-ort01 = wa_valid-ort01 . "City
wa_invalid-ort02 = wa_valid-ort02 . "District
wa_invalid-pstlz = wa_valid-pstlz . "Postal Code
wa_invalid-state = wa_valid-state . "Region(State)
wa_invalid-land1 = wa_valid-land1 . "Country
wa_invalid-telnr = wa_valid-telnr . "Telephone No
wa_invalid-wkwng = wa_valid-wkwng . "Company Housing
wa_invalid-error = wa_data_create-message.
APPEND wa_invalid TO t_invalid. "appending wa_invalid to internal table
ELSE.
APPEND wa_valid TO t_v_final. "appending wa_valid to another internal table for the final count of valid records
ENDIF.
CLEAR: wa_invalid, "clearing work area of invalid
wa_valid. "clearing work area of valid
ENDFORM. " sub_BAPI_ADDRESSEMP_CREATE
*& Form sub_bapi_employee_dequeue
Subroutine to unlock an employee
FORM sub_bapi_employee_dequeue .
DATA : wa_return_deque TYPE bapireturn1.
*This function module is used to unlock an employee so that the records
*stored for this person can be accessed.
*If an employee is locked using the ENQUEUE method,the user who set the
*lock can access this employee's records.
*Other users are denied access to these records.
CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
EXPORTING
number = wa_valid-pernr "Personal number
IMPORTING
return = wa_return_deque. "for error values returned
ENDFORM. " sub_bapi_employee_dequeue
*& Form sub_download_error_file
Subroutine to download error file for rectifications
FORM sub_download_error_file .
PROVIDE A VARIABLE FOR HOLDING FLAT FILE
CONSTANTS : lc_ftype TYPE char10 VALUE 'ASC',
lc_fsepe TYPE char01 VALUE 'X',
lc_err TYPE char5 VALUE '_err.', "constant to change error file name
lc_period TYPE c VALUE '.'. "constant to change error file name
g_errfile = p_file. "STORE FILENAME IN VARIABLE(l_FILE)
SHIFT g_errfile BY 4 PLACES RIGHT CIRCULAR.
REPLACE lc_period WITH lc_err INTO g_errfile. "lc_err to truncate .txt and lc_period to add _err.txt
SHIFT g_errfile BY 8 PLACES LEFT CIRCULAR.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = g_errfile
filetype = lc_ftype
write_field_separator = lc_fsepe
TABLES
data_tab = t_invalid
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22
IF sy-subrc NE 0.
MESSAGE i003.
ENDIF.
ENDFORM. " sub_download_error_file
*& Form sub_details
Subroutine for loading details
FORM sub_details .
DATA: l_count_total TYPE i, "variable to count total no of records
l_count_valid TYPE i, "variable to count no of records uploaded
l_count_invalid TYPE i. "variable to count total no of error records
ULINE.
WRITE :/71 text-018 . "title
DESCRIBE TABLE t_infotype LINES l_count_total. "To count no of lines in internal table
WRITE :/,text-019 ,30 text-020, 32 l_count_total,157 text-021,164 text-020, 166 sy-datum.
DESCRIBE TABLE t_v_final LINES l_count_valid. "To count no of lines in internal table
WRITE : text-022,30 text-020,32 l_count_valid,157 text-023,164 text-020, 166 sy-uzeit.
DESCRIBE TABLE t_invalid LINES l_count_invalid. "To count no of lines in internal table
WRITE : text-025,30 text-020,32 l_count_invalid,157 text-024,164 text-020, 166 sy-uname.
WRITE :/,text-026 ,30 text-020 , 40 g_file . "name of the error file
Print if only invalid records exist
IF NOT t_invalid[] IS INITIAL.
WRITE :/,text-027 ,30 text-020 , 40 g_errfile . "variable to count total no of error records
IF t_invalid IS INITIAL.
g_errfile = text-029.
ENDIF.
WRITE :/ text-028.
ULINE.
WRITE :/ sy-vline,2 text-030,17 sy-vline, 20 text-031,178 sy-vline. "headings -
Maintain texts for Infotype 0019 via ABAP.
Hi,
The issue is related to maintaining texts for Infotype 0019. I have a program below. The main problem is I am facing is for some records it inserts text in Infotype (0019) but for some it does not. Can anyone suggest why so or a way to resolve this problem ???
REPORT ytbctest009.
TABLES: pernr, pcl1.
INFOTYPES: 0019.
DATA: key LIKE pskey.
DATA: BEGIN OF ptext OCCURS 200.
DATA: line(72).
DATA: END OF ptext.
SELECTION-SCREEN BEGIN OF BLOCK abc WITH FRAME TITLE text-001.
PARAMETERS: p_pernr LIKE pernr-pernr.
SELECTION-SCREEN END OF BLOCK abc.
ptext-line = 'TEST 1'.
APPEND ptext.
ptext-line = 'Test 2'.
APPEND ptext.
ptext-line = 'Test 3'.
APPEND ptext.
rp-read-infotype p_pernr 0019 0019 '18000101' '99991231'.
SORT p0019 DESCENDING.
READ TABLE p0019 INDEX 1.
p0019-itxex = 'X'.
MOVE-CORRESPONDING p0019 TO key .
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0019'
number = p_pernr
validityend = p0019-endda
validitybegin = p0019-begda
record = p0019
operation = 'MOD'.
EXPORT ptext TO DATABASE pcl1(tx) ID key.
Thanks in advance.Hi Rajashree,
I hope , below code will solve the problem.
<b>Main Code</b>
FUNCTION zhr_mustus_update_it0019.
*"*"Local interface:
*" IMPORTING
*" VALUE(IM_PERNR) TYPE P0019-PERNR OPTIONAL
*" VALUE(IM_USRID) TYPE PA0105-USRID OPTIONAL
*" VALUE(IM_SUBTY) TYPE P0019-SUBTY
*" VALUE(IM_TERMN) TYPE P0019-TERMN OPTIONAL
*" VALUE(IM_MNDAT) TYPE P0019-MNDAT OPTIONAL
*" VALUE(IM_BVMRK) TYPE P0019-BVMRK OPTIONAL
*" VALUE(IM_TEXT) TYPE CHAR30 OPTIONAL
*" EXPORTING
*" VALUE(EX_RETURN_MESSAGE) TYPE STRING
*" VALUE(EX_MESSAGE_ID) TYPE ARBGB
*" VALUE(EX_MESSAGE_NUMBER) TYPE MSGNR
*" EXCEPTIONS
*" SYSTEM_FAILURE
*" COMMUNICATION_FAILURE
REFRESH bdcdata.
REFRESH it_bdc_message.
* Validations
PERFORM validations USING im_usrid im_subty im_mndat
CHANGING im_pernr
g_task_date
g_rem_date.
* Return message
MOVE:
g_message TO ex_return_message,
'ZMSGHR' TO ex_message_id,
g_msgno TO ex_message_number.
* If there any error don't process
CHECK ex_return_message IS INITIAL.
* If reminder date is missing then its creation
IF im_mndat IS INITIAL.
* Fill BDC for PA30 Creation
PERFORM fill_bdc_for_creation USING im_pernr
im_subty
im_text
g_task_date
g_rem_date.
ELSE.
* Its a change, Fill BDC for PA30 change
PERFORM fill_bdc_for_change USING im_pernr
im_subty
im_termn
im_bvmrk
im_text.
ENDIF.
* Call transaction PA30
PERFORM bdc_call_transaction.
* Return message
MOVE:
g_message TO ex_return_message,
g_msgid TO ex_message_id,
g_msgno TO ex_message_number.
ENDFUNCTION.
<b>All Above Subroutines,</b>
*& Form Validations
* Validations for MUS/TUS
* -->U_USRID User id for TUS
* -->U_SUBTY Subtype 10 - MUS, 11 - TUS
* -->U_MNDAT Reminder date
* <--PERNR Person for MUS
* <--U_TASK_DATE Task date
* <--U_REM_DATE Reminder date
FORM validations USING u_usrid LIKE pa0105-usrid
u_subty LIKE p0019-subty
u_mndat LIKE p0019-mndat
CHANGING u_pernr LIKE p0019-pernr
u_task_date LIKE sy-datum
u_rem_date LIKE sy-datum.
DATA:
BEGIN OF it_tmp_0019 OCCURS 0,
termn LIKE pa0019-termn,
END OF it_tmp_0019.
CLEAR g_message.
* Validations for MUS
IF u_subty EQ c_subty_10.
MOVE sy-datum TO u_task_date.
IF u_pernr IS INITIAL.
* Person number is missing
MOVE:
text-001 TO g_message,
'003' TO g_msgno.
ELSEIF u_mndat IS INITIAL.
* Its creation, check if there is already a open item
SELECT pernr
FROM pa0019
INTO u_pernr
WHERE pernr EQ u_pernr
AND subty EQ u_subty
AND bvmrk NE '2'.
EXIT.
ENDSELECT.
IF sy-subrc EQ 0.
* Throw an error if there is already a open item
MOVE:
text-006 TO g_message,
'004' TO g_msgno.
ENDIF.
ENDIF.
ENDIF.
* Validations for TUS
IF u_subty EQ c_subty_11.
IF u_usrid IS INITIAL
AND u_pernr IS INITIAL.
* User/Person number is missing
MOVE:
text-002 TO g_message,
'005' TO g_msgno.
ELSEIF NOT u_usrid IS INITIAL.
SELECT pernr
FROM pa0105
INTO u_pernr
WHERE usrid EQ u_usrid.
ENDSELECT.
IF u_pernr IS INITIAL.
* Person number is missing
MOVE:
text-001 TO g_message,
'006' TO g_msgno.
ENDIF.
ENDIF.
IF g_message IS INITIAL.
SELECT termn
FROM pa0019
INTO TABLE it_tmp_0019
WHERE pernr EQ u_pernr
AND subty EQ u_subty
AND bvmrk NE '2'.
READ TABLE it_tmp_0019 WITH KEY termn = sy-datum.
* There is no open task for today
IF sy-subrc NE 0.
MOVE sy-datum TO u_task_date.
ELSE.
* There is a open task for today, new task should be created next
* available date and reminder date is yesterday's date
SORT it_tmp_0019 DESCENDING.
READ TABLE it_tmp_0019 INDEX 1.
u_task_date = it_tmp_0019-termn + 1.
u_rem_date = sy-datum - 1.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. "VALIDATIONS
*& Form Fill_bdc_for_creation
* BDC data for creation , Transaction PA30
* -->U_PERNR Person
* -->U_SUBTY Subty MUS - 10, TUS - 11
* -->U_TEXT Text
* -->U_TASK_DATE Task date
* -->U_REM_DATE Task date
FORM fill_bdc_for_creation USING u_pernr LIKE p0019-pernr
u_subty LIKE p0019-subty
u_text TYPE char30
u_task_date LIKE sy-datum
u_rem_date LIKE sy-datum.
* Scree1
DATA:
l_task_date(10),
l_rem_date(10).
* Use system date as Task date
WRITE:
u_task_date TO l_task_date,
u_rem_date TO l_rem_date.
PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.
PERFORM bdc_field USING 'RP50G-PERNR'
u_pernr.
PERFORM bdc_field USING 'RP50G-CHOIC'
'0019'.
PERFORM bdc_field USING 'RP50G-SUBTY'
u_subty.
PERFORM bdc_field USING 'BDC_OKCODE'
'=INS'.
* Screen2
PERFORM bdc_dynpro USING 'MP001900' '2000'.
PERFORM bdc_field USING 'P0019-TMART'
u_subty.
PERFORM bdc_field USING 'P0019-TERMN'
l_task_date.
IF NOT u_rem_date IS INITIAL.
PERFORM bdc_field USING 'P0019-MNDAT'
l_rem_date.
ENDIF.
PERFORM bdc_field USING 'RP50M-TEXT1'
u_text.
PERFORM bdc_field USING 'BDC_OKCODE'
'/00'.
PERFORM bdc_dynpro USING 'MP001900' '2000'.
PERFORM bdc_field USING 'P0019-TMART'
u_subty.
PERFORM bdc_field USING 'P0019-TERMN'
l_task_date.
IF NOT u_rem_date IS INITIAL.
PERFORM bdc_field USING 'P0019-MNDAT'
l_rem_date.
ENDIF.
PERFORM bdc_field USING 'RP50M-TEXT1'
u_text.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
ENDFORM. "fill_bdc_for_creation
*& Form fill_bdc_for_change
* BDC data for change , Transaction PA30
* -->U_PERNR Person
* -->U_SUBTY subtype MUS - 10 , TUS - 11
* -->U_MNDAT Reminder date
* -->U_BVMRK Status
* -->U_TEXT Text
FORM fill_bdc_for_change USING u_pernr LIKE p0019-pernr
u_subty LIKE p0019-subty
u_termn LIKE p0019-termn
u_bvmrk LIKE p0019-bvmrk
u_text TYPE char30.
* Scree1
DATA l_termn_date(10).
WRITE u_termn TO l_termn_date.
PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.
PERFORM bdc_field USING 'RP50G-PERNR'
u_pernr.
PERFORM bdc_field USING 'RP50G-CHOIC'
'0019'.
PERFORM bdc_field USING 'RP50G-SUBTY'
u_subty.
PERFORM bdc_field USING 'RP50G-BEGDA'
l_termn_date.
PERFORM bdc_field USING 'RP50G-ENDDA'
l_termn_date.
PERFORM bdc_field USING 'BDC_OKCODE'
'=MOD'.
* Screen2
PERFORM bdc_dynpro USING 'MP001900' '2000'.
PERFORM bdc_field USING 'P0019-TMART'
u_subty.
PERFORM bdc_field USING 'P0019-TERMN'
l_termn_date.
PERFORM bdc_field USING 'RP50M-TEXT1'
u_text.
PERFORM bdc_field USING 'P0019-BVMRK'
u_bvmrk.
PERFORM bdc_field USING 'BDC_OKCODE'
'=UPD'.
ENDFORM. "fill_bdc_for_change
FORM bdc_call_transaction.
DATA:
l_mode(1) TYPE c VALUE 'N',
l_lines TYPE i,
l_msgvar1 LIKE balm-msgv1,
l_msgvar2 LIKE balm-msgv2,
l_msgvar3 LIKE balm-msgv3,
l_msgvar4 LIKE balm-msgv4.
CALL TRANSACTION 'PA30' USING bdcdata MODE l_mode
MESSAGES INTO it_bdc_message.
* Get last message
DESCRIBE TABLE it_bdc_message LINES l_lines.
READ TABLE it_bdc_message INDEX l_lines.
MOVE:
it_bdc_message-msgid TO g_msgid,
it_bdc_message-msgnr TO g_msgno,
it_bdc_message-msgv1 TO l_msgvar1,
it_bdc_message-msgv2 TO l_msgvar2,
it_bdc_message-msgv3 TO l_msgvar3,
it_bdc_message-msgv4 TO l_msgvar4.
* Prepare message
CALL FUNCTION 'MESSAGE_PREPARE'
EXPORTING
language = sy-langu
msg_id = g_msgid
msg_no = g_msgno
msg_var1 = l_msgvar1
msg_var2 = l_msgvar2
msg_var3 = l_msgvar3
msg_var4 = l_msgvar4
IMPORTING
msg_text = g_message
EXCEPTIONS
function_not_completed = 1
message_not_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MOVE text-005 TO g_message.
ENDIF.
ENDFORM. "BDC_FIELD
* Start new screen *
FORM bdc_dynpro USING program dynpro.
CLEAR bdcdata.
bdcdata-program = program.
bdcdata-dynpro = dynpro.
bdcdata-dynbegin = 'X'.
APPEND bdcdata.
ENDFORM. "BDC_DYNPRO
* Insert field *
FORM bdc_field USING fnam fval.
CLEAR bdcdata.
bdcdata-fnam = fnam.
bdcdata-fval = fval.
APPEND bdcdata.
ENDFORM. "BDC_FIELD
Cheers.
Santosh.
Maybe you are looking for
-
Convert source code (widget) to html snippet code
hey been searching google for about 45 minutes now and for the life of me i can't find information on how to change source code that i have for a widget into usable html code that i can embed into iWeb08' does this makes sense? I created a widget in
-
. . . when I set it to edit in Full Screen or via an outside like like PS. By going in to Preferences I can set it to edit when I double-click an image with different actions via: In Main Window: Stops Responding In Separate Window: Stops Responding
-
Hi Guys... Thanks for helping all the time when ever i am need of ,however I am here with a problem again.... Description : I have a Zreport that has been developed. Now i have 3 transactions for the Zreport , These 3 transactions serve for
-
Pricing Error: Mandatory condition List price is missing
Hi All, When an Order is created in ISA with a material with mandatory pricing condition is zero an error is raised. This is the right functionality. Due to this the order is not replicated into ECC. Is there any suggestion as to how this error messa
-
How to Push photos to parent's iPad?
I'm sure I'm not the only one looking for a solution to this. Just gave our parents an iPad. We'd like to set them up with a few galleries and then be able to push photographs into the galleries so they can easily see new pictures. They are connectin