1.moved to marknsap.blogspot.com - marksap.blogspot.com
Tuesday, December 20, 2011
Note: Changing payslip in portal
You need to make a new form using smartforms and put it in EDPDF .
1. HRFOR - This feature decides whether to use HRFORMS or CEDT forms
(configured in PE51) for the payslip. If HRFORMS, the name of HRFORM has
to be mentioned here. If PE51 needs to be used then $CEDT$ should be
specified.
2. EDTIN - This should hold the value of the variant to be executed in
the CEDT program (payslip program). The variant should be proper with
the with the correct CEDT (payslip) form name and other parameters.
3. EDPDF - The name of the smartform (standard smartform
HR_ESS_PAYSLIP_TO_PDF or customer specific form) used to show the output
in the ESS.
Abap Creating a workable button on the selection screen
*& Report Y_MARK_TEST_BUTTON
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT Y_MARK_TEST_BUTTON.
TABLES sscrfields.
DATA: ld_filename TYPE string,
ld_path TYPE string,
ld_fullpath TYPE string,
ld_result TYPE i,
gd_file TYPE c.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS : P_FILE LIKE RLGRAP-FILENAME default 'C:\EMAIL_RESULT.XLS'.
SELECTION-SCREEN: BEGIN OF LINE.
SELECTION-SCREEN PUSHBUTTON (20) dl_excel USER-COMMAND dl_excel. "button!
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B1.
* At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
* Display save dialog window
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
* window_title = ' '
default_extension = 'XLS'
default_file_name = 'EMAIL_RESULT'
initial_directory = 'C:\'
CHANGING
filename = ld_filename
path = ld_path
fullpath = ld_fullpath
user_action = ld_result.
p_file = ld_fullpath.
AT SELECTION-SCREEN OUTPUT.
MOVE 'Download' TO dl_excel. "giving the button label
AT SELECTION-SCREEN.
case sy-ucomm.
when 'DL_EXCEL'.
"DO WHAT EVER YOU LIKE
endcase.
abap : How to save a file using a dialog box
*Selecting a file to save too, plus inserting default file extension .xls
tables rlgrap.
DATA: ld_filename TYPE string,
ld_path TYPE string,
ld_fullpath TYPE string,
ld_result TYPE i,
gd_file TYPE c.
selection-screen begin of block m with frame.
PARAMETERS: p_file TYPE rlgrap-filename.
selection-screen end of block m.
* At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
* Display save dialog window
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
* window_title = ' '
default_extension = 'XLS'
default_file_name = 'accountsdata'
initial_directory = 'c:\temp\'
CHANGING
filename = ld_filename
path = ld_path
fullpath = ld_fullpath
user_action = ld_result.
p_file = ld_fullpath.
source : http://www.sapdev.co.uk/file/file_objsave.htm
Abap how to read a comma delimited data into internal table
declare an internal table like:
data: begin of i_rec occurs 0,
filler(200),
end of i_rec.
data: begin of itab occurs 0,
field1,
field2,
...
end of itab.
Itab is the table you want to fill, i_rec is just a temporary intermediary table.
data: sep_field(1) value ','.
that's your separator (comma or something else).
First call the function GUI_UPLOAD and fill table i_rec with the data in your file.
then:
loop at i_rec.
split i_rec-filler at sep_field into itab-field1 itab-field2 ...
append itab.
clear itab.
endloop.
this should do the trick for as far as I know.
good luck,
ioana
source
http://sap.ittoolbox.com/groups/technical-functional/sap-dev/comma-delimited-file-to-internal-table-151418
Monday, December 19, 2011
Abap how to create an excel file sample
Parameters: P_file like RLGRAP-FILENAME.
data : begin of int_head occurs 0,
Filed1(20) type c, " Header Data
end of int_head.
data : begin of int_data occurs 0,
Field1(20) type c, " Data
Field2(20) type c,
Field3(20) type c,
Field4(20) type c,
end of int_data.
int_head-Filed1 = 'Sales Ord'.
APPEND int_head.
CLEAR int_head.
int_head-Filed1 = 'Sold-to-Party'.
APPEND int_head.
CLEAR int_head.
int_head-Filed1 = 'Purchase Ord'.
APPEND int_head.
CLEAR int_head.
int_head-Filed1 = 'Ship-to-Party'.
APPEND int_head.
CLEAR int_head.
int_data-field1 = '1JOHN'.
int_data-field2 = '2TOM'.
int_data-field3 = '3BRAD'.
int_data-field4 = '4PETER'.
Append int_data.
Clear int_data.
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = p_file " path offile where u need to download
* CREATE_PIVOT = 0
* DATA_SHEET_NAME = ' '
* PIVOT_SHEET_NAME = ' '
* PASSWORD = ' '
* PASSWORD_OPTION = 0
TABLES
* PIVOT_FIELD_TAB =
data_tab = int_data "internal table with data
fieldnames = int_head "internal table with header
EXCEPTIONS
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_filename = 6
invalid_pivot_fields = 7
download_problem = 8
OTHERS = 9
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
source
http://abaplovers.blogspot.com/2008/05/abap-internal-table-to-excel-sheet.html
How to debug universal worklist, approval pending list, approval program.
Recent workflow debugging for supervisor
How do we debug a program which has been configured in swfvisu?
Applicant we can easily debugged from the
Transaction code = SE80
But as the work flow comes into the picture the data/application is routed to the supervisor
STEP 1
Still using the transaction code SE80.
Put a debugmode under
- Component Controller -> Method -> wdoinit (place any break point there tips: best at the first line)
- Test run first! Let it stay in the debug mode and then proceed to STEP 2
STEP 2
Log into the portal
1.CLICK on the work ( universal worklist - the place where you can see the approval's pending list)
2.CLICK on the document that is pending
STEP 3
Once step 1 and step 2 is achieved.
You can start you exploration to debug which ever error you can find in the approval webdynpro
Monday, December 12, 2011
Sample ALV Grid program using the function module REUSE_ALV_GRID_DISPLAY
Sample ALV Grid program using the function module REUSE_ALV_GRID_DISPLAY
By Vikram Chellappa, Mouri Tech Solutions
*&---------------------------------------------------------------------* *& Report ZALV_REPORT_SFLIGHT *& *&---------------------------------------------------------------------* * Published at SAPTechnical.COM *&---------------------------------------------------------------------*
REPORT ZALV_REPORT_SFLIGHT. TABLES : SFLIGHT. TYPE-POOLS : SLIS.
**INTERNAL TABLE DECLARTION DATA : WA_SFLIGHT TYPE SFLIGHT, IT_SFLIGHT TYPE TABLE OF SFLIGHT.
**DATA DECLARTION DATA: FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE, GD_LAYOUT TYPE SLIS_LAYOUT_ALV, GD_REPID LIKE SY-REPID, G_SAVE TYPE C VALUE 'X', G_VARIANT TYPE DISVARIANT, GX_VARIANT TYPE DISVARIANT, G_EXIT TYPE C, ISPFLI TYPE TABLE OF SPFLI.
* To understand the importance of the following parameter, click here. **SELECTION SCREEN DETAILS SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002 . PARAMETERS: VARIANT LIKE DISVARIANT-VARIANT. SELECTION-SCREEN END OF BLOCK B1. **GETTING DEFAULT VARIANT INITIALIZATION. GX_VARIANT-REPORT = SY-REPID. CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET' EXPORTING I_SAVE = G_SAVE CHANGING CS_VARIANT = GX_VARIANT EXCEPTIONS NOT_FOUND = 2. IF SY-SUBRC = 0. VARIANT = GX_VARIANT-VARIANT. ENDIF.
**PERFORM DECLARATIONS START-OF-SELECTION. PERFORM DATA_RETRIVEL. PERFORM BUILD_FIELDCATALOG. PERFORM DISPLAY_ALV_REPORT.
*&---------------------------------------------------------------------* *& Form BUILD_FIELDCATALOG *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM BUILD_FIELDCATALOG .
FIELDCATALOG-FIELDNAME = 'CARRID'. FIELDCATALOG-SELTEXT_M = 'Airline Code'. FIELDCATALOG-COL_POS = 0. APPEND FIELDCATALOG TO FIELDCATALOG. CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'CONNID'. FIELDCATALOG-SELTEXT_M = 'Flight Connection Number'. FIELDCATALOG-COL_POS = 1. APPEND FIELDCATALOG TO FIELDCATALOG. CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'FLDATE'. FIELDCATALOG-SELTEXT_M = 'Flight date'. FIELDCATALOG-COL_POS = 2. APPEND FIELDCATALOG TO FIELDCATALOG. CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'PRICE'. FIELDCATALOG-SELTEXT_M = 'Airfare'. FIELDCATALOG-COL_POS = 3. FIELDCATALOG-OUTPUTLEN = 20. APPEND FIELDCATALOG TO FIELDCATALOG. CLEAR FIELDCATALOG. ENDFORM. " BUILD_FIELDCATALOG *&---------------------------------------------------------------------* *& Form DISPLAY_ALV_REPORT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM DISPLAY_ALV_REPORT . GD_REPID = SY-REPID. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING I_CALLBACK_PROGRAM = GD_REPID I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE' "see FORM I_CALLBACK_USER_COMMAND = 'USER_COMMAND' IT_FIELDCAT = FIELDCATALOG[] I_SAVE = 'X' IS_VARIANT = G_VARIANT TABLES T_OUTTAB = IT_SFLIGHT EXCEPTIONS PROGRAM_ERROR = 1 OTHERS = 2. IF SY-SUBRC <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. ENDFORM. "DISPLAY_ALV_REPORT
" DISPLAY_ALV_REPORT *&---------------------------------------------------------------------* *& Form DATA_RETRIVEL *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM DATA_RETRIVEL . SELECT * FROM SFLIGHT INTO TABLE IT_SFLIGHT. ENDFORM. " DATA_RETRIVEL
*-------------------------------------------------------------------* * Form TOP-OF-PAGE * *-------------------------------------------------------------------* * ALV Report Header * *-------------------------------------------------------------------* FORM TOP-OF-PAGE. *ALV Header declarations DATA: T_HEADER TYPE SLIS_T_LISTHEADER, WA_HEADER TYPE SLIS_LISTHEADER, T_LINE LIKE WA_HEADER-INFO, LD_LINES TYPE I, LD_LINESC(10) TYPE C.
* Title WA_HEADER-TYP = 'H'. WA_HEADER-INFO = 'SFLIGHT Table Report'. APPEND WA_HEADER TO T_HEADER. CLEAR WA_HEADER.
* Date WA_HEADER-TYP = 'S'. WA_HEADER-KEY = 'Date: '. CONCATENATE SY-DATUM+6(2) '.' SY-DATUM+4(2) '.' SY-DATUM(4) INTO WA_HEADER-INFO. "todays date APPEND WA_HEADER TO T_HEADER. CLEAR: WA_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' EXPORTING IT_LIST_COMMENTARY = T_HEADER. ENDFORM. "top-of-page
SOURCE
http://www.saptechnical.com/Tutorials/ALV/SampleALVGridProgram.htm
Abap: Country Grouping
Tuesday, November 15, 2011
SAP script
- to only preview the form: options-tdpreview='X' (options-tdnoprint forbids print even from preview)
- to get OTF data instead of printing: options-tdgetotf='X'
- to output OTF data to memory buffer instead of printing: device='OTF_MEM'
Code: |
REPORT z_sapscript_form. data: w_options type itcpo, w_result type itcpp, w_otf like itcoo occurs 0 with header line, w_ascii like tline occurs 0 with header line, w_device(40) type c, w_num like sy-tabix. parameters: printer like tsp03-padest lower case default 'locl', layoutst like rsscf-tdform default 'MEDRUCK'. selection-screen: begin of line. parameters p_prn radiobutton group rad0. selection-screen: comment 4(60) cmt_prn for field p_prn, end of line. selection-screen: begin of line. parameters p_pre radiobutton group rad0. selection-screen: comment 4(60) cmt_pre for field p_pre, end of line. selection-screen: begin of line. parameters p_mem radiobutton group rad0. selection-screen: comment 4(60) cmt_mem for field p_mem, end of line. selection-screen: begin of line. parameters p_otf radiobutton group rad0. selection-screen: comment 4(60) cmt_otf for field p_otf, end of line. initialization. cmt_prn = 'Print to spool'. cmt_pre = 'Only create form and preview, no print'. cmt_mem = 'Output OTF to memory buffer and convert to ASCII'. cmt_otf = 'Only get OTF data'. start-of-selection. perform: form_open, print_item, form_close. case 'X'. when p_prn. write: / 'See Spool#', w_result-tdspoolid, '(', w_result-tdpages, ' pages )'. when p_pre. when p_otf. loop at w_otf. write / w_otf. endloop. when p_mem. perform get_ascii. endcase. *---------------------------------------------------------------------* * FORM FORM_OPEN * *---------------------------------------------------------------------* * Start of printing the form * *---------------------------------------------------------------------* form form_open. w_options-tddest = printer. w_device = 'PRINTER'. "default case 'X'. when p_pre. w_options-tdpreview = 'X'. w_options-tdnoprint = 'X'. when p_prn. when p_mem. w_device = 'OTF_MEM'. when others. w_options-tdgetotf = 'X'. endcase. call function 'OPEN_FORM' exporting device = w_device dialog = ' ' form = layoutst options = w_options exceptions canceled = 1 device = 2 form = 3 options = 4 unclosed = 5 mail_options = 6 archive_error = 7 invalid_fax_number = 8 more_params_needed_in_batch = 9 spool_error = 10 others = 11. write: / 'Form open. Return code =', sy-subrc. if sy-subrc <> 0. message id sy-msgid type 'I' number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. endif. endform. *&---------------------------------------------------------------------* *& Form PRINT_ITEM *&---------------------------------------------------------------------* * Print form item * *----------------------------------------------------------------------* form print_item. call function 'WRITE_FORM' exceptions element = 1 function = 2 type = 3 unopened = 4 unstarted = 5 window = 6 bad_pageformat_for_print = 7 spool_error = 8 others = 9. write: / 'Form print. Return code =', sy-subrc. if sy-subrc <> 0. message id sy-msgid type 'I' number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. endif. endform. " PRINT_ITEM *---------------------------------------------------------------------* * FORM FORM_CLOSE * *---------------------------------------------------------------------* * End of printing the form * *---------------------------------------------------------------------* form form_close. call function 'CLOSE_FORM' importing result = w_result tables otfdata = w_otf exceptions unopened = 1 bad_pageformat_for_print = 2 send_error = 3 spool_error = 4 others = 5. write: / 'Form close. Return code =', sy-subrc, 'Spool#', w_result-tdspoolid. if sy-subrc <> 0. message id sy-msgid type 'I' number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. else. describe table w_otf lines w_num. write: / 'OTF has', w_num, 'lines.'. endif. endform. *&---------------------------------------------------------------------* *& Form get_ascii *&---------------------------------------------------------------------* * convert OTF from memory to ASCII text *----------------------------------------------------------------------* form get_ascii. call function 'CONVERT_OTF_MEMORY' tables lines = w_ascii exceptions memory_empty = 1 err_max_linewidth = 2 err_format = 3 err_conv_not_possible = 4 others = 5. write: / 'Convert OTF memory. Return code =', sy-subrc. if sy-subrc <> 0. message id sy-msgid type 'I' number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. else. describe table w_ascii lines w_num. write: / 'OTF has', w_num, 'lines.'. loop at w_ascii. write: / w_ascii. endloop. endif. endform. " get_ascii |
CLOSE_FORM - End SAPscript layout set printing
- spool #: result-tdspoolid
- OTF data: otfdata (when options-tdgetotf='X' in OPEN_FORM)
WRITE_FORM - Output SAPscript text element in form window
CONTROL_FORM - Control SAPscript form output
- issue command to the form, e.g. exporting command = 'NEW-PAGE'
CONVERT_OTF_MEMORY - Convert SAPscript OTF from memory into text format
output: table of structure TLINE (OTF saved to memory buffer by OPEN_FORM)
SAVE_OTF_TO_MEMORY - Write OTF format to memory
export|import OTF internal table to|from memory id ...
READ_OTF_FROM_MEMORY - Read OTF from memory
PRINT_OTF - print OTF from internal table
DISPLAY_OTF - Display an OTF table on the screen
DISPLAY_POSTSCRIPT - Display a postscript table on the screen tables postscript structure itcps
CONVERT_OTF - Convert OTF format to various formats (TLINE table) ASCII or PDF
Code: |
CALL FUNCTION "CONVERT_OTF" EXPORTING FORMAT = "PDF" IMPORTING BIN_FILESIZE = FILE_LEN TABLES OTF = OTFDATA LINES = PDFDATA EXCEPTIONS ERR_MAX_LINEWIDTH = 1 ERR_FORMAT = 2 ERR_CONV_NOT_POSSIBLE = 3 OTHERS = 4. |
CONVERT_OTF_2_PDF - Convert OTF to PDF (TLINE table).
OTF can be filled used archivelink. Calls CONVERT_OTF.
CONVERT_OTF_2_PDF_ARCHIVELINK - Convert OTF to PDF (TLINE table).
Calls CONVERT_OTF. Looks like the function names for these two functions are mixed up J
CONVERT_OTF_AND_FAX
CONVERT_OTF_AND_MAIL
CONVERT_OTFSPOOLJOB_2_PDF
Input: spool # (SAPscript: tsp01-rqdoctype='OTF'); Output: PDF as internal table (TLINE)
CONVERT_ABAPSPOOLJOB_2_PDF
Input: spool # (ABAP listing: tsp01-rqdoctype='LIST'); Output: PDF as internal table (TLINE)
OTF_CONVERT - wraps several other function modules. Will convert OTF to ASCII or PDF
SX_OBJECT_CONVERT_OTF_PDF - Conversion From OTF to PDF (SAPScript conversion)
SX_OBJECT_CONVERT_OTF_PRT - Conversion From OTF to Printer Format (SAPScript conversion)
SX_OBJECT_CONVERT_OTF_RAW - Conversion From OTF to ASCII (SAPScript conversion)
Monday, November 14, 2011
To assign enter button as execute in selection screen
COMMENT 1(31) TEXT-002 FOR FIELD IN_YEAR MODIF ID A.
PARAMETERS: IN_YEAR(4) MODIF ID A. " a field
SELECTION-SCREEN PUSHBUTTON (20) execut USER-COMMAND execut MODIF ID A. "button!
SELECTION-SCREEN END OF LINE.
===========================================
AT SELECTION-SCREEN OUTPUT.
MOVE 'Execute' TO execut. "giving the button label
..
...
....
===========================================
AT SELECTION-SCREEN.
if sscrfields-ucomm eq 'EXECUT'.
sscrfields-ucomm = 'ONLI'. " this is the execute value passed!
endif.
..
...
....
HR_GET_EMPLOYEES_FROM_USER
DATA : ee_tab TYPE PERNR_US_TAB,
wa_ee_tab type line of PERNR_US_TAB.
* get pernr, molga, ename
CALL FUNCTION 'HR_GET_EMPLOYEES_FROM_USER'
EXPORTING
user = sy-uname
TABLES
ee_tab = ee_tab.
LOOP AT ee_tab into wa_ee_tab.
ENDLOOP.
PNPPERNR-SIGN = 'I'.
PNPPERNR-OPTION = 'EQ'.
PNPPERNR-LOW = wa_ee_tab-pernr.
APPEND PNPPERNR.
How to use a table with no header
wa_ee_tab type line of PERNR_US_TAB.
* get pernr, molga, ename
CALL FUNCTION 'HR_GET_EMPLOYEES_FROM_USER'
EXPORTING
user = sy-uname
TABLES
ee_tab = ee_tab.
LOOP AT ee_tab into wa_ee_tab.
ENDLOOP.
Sunday, November 13, 2011
How to hide certain fields or button in your selection screen
*& Report Y_MARK
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT Y_MARK.
DATA: D_UCOMM LIKE SY-UCOMM.
PARAMETERS: P_GRPA1(10) MODIF ID A,
P_GRPA2(5) MODIF ID A,
P_GRPB1(2) MODIF ID B.
PARAMETERS: P_ACTA RADIOBUTTON GROUP RAD1 USER-COMMAND ACT DEFAULT 'X',
P_ACTB RADIOBUTTON GROUP RAD1.
AT SELECTION-SCREEN.
D_UCOMM = SY-UCOMM.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF P_ACTA = 'X'.
IF SCREEN-GROUP1 = 'B'.
SCREEN-ACTIVE = 0.
ENDIF.
ELSEIF P_ACTB = 'X'.
IF SCREEN-GROUP1 = 'A'.
SCREEN-ACTIVE = 0.
ENDIF.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
START-OF-SELECTION.
Tuesday, November 8, 2011
The maintenance dialog for zXXXXX is incomplete or not defined
Use tcode SE11, enter the table name click change. In the next screen, click Utitlies-->table maintenance generator.
Enter &NC& as the auth group.
Enter the function group to use (ex. Z_TABMAINT)
click One Step, enter '1' as the screen number. Click the create button.
Once generated, you can use it by going to SM30, enter table name and click maintain.
Source
http://forums.sdn.sap.com/thread.jspa?threadID=1087759
IAC - how to create
Steps to create IAC iview.
1. Create a system object for R/3 with ITS property category also.
2. create a Service in transaction using SICF. The below thread will help you.
https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2204
3. create an an iview and give the service name in IAC textbox not R/3 System name.
Also check:
https://www.sdn.sap.com/irj/sdn/thread?threadID=243082
http://help.sap.com/saphelp_nw04/helpdata/en/44/216fe21784648ee10000000a1553f7/frameset.htm
M again mentioning all the steps for IAC iview creation, plz check.
Steps to display the SAP Transaction as Internet Application Component (IAC) in Portal
The following three tasks have to be performed step by step:
1.Creating the IAC
2.Activating the IAC
3.Creating an IAC iview in the portal
Creating an IAC
1)Go to transaction sicf. Click on the "watch"button. Under Virtual Host / Services expand Default_host > SAP > bc > gui > sap > ITS. Now right click over ITS and select New Sub-Element.
2)In the new dialog box give the name of the service.
3)Now write a description in the description box. In the drop box corresponding to GUI Link select the option Yes. Now click the GUI Transaction button and enter the parameters as shown below.
Parameter Name Value
~TRANSACTION sm36
~THEME 99
~generateDynpro 1
~noHeaderOkCode 1
4)Now go to the tab Handler List and maintain the parameter CL_HTTP_EXT_ITS.
Now click on the save button from the top and save it.
You can now see the service under ITS.
Activating the service
After saving the IAC, we need to activate the service. Select the service under ITS, right click over it and select Activate Service. The service will get activated.
Creating an IAC iview in the portal
We need to create an iview which in tern will use a system to connect to the ITS.
In the WAS property of the system maintain the following property
Web As Host Name
Web As Path /sap/bc/gui/sap/its/
Web As Protocol HTTP/HTTPS
Under Content Administration > Portal Content create an iview of type SAP IAC iview and specify the system alias name and the IAC.
source
http://forums.sdn.sap.com/thread.jspa?threadID=841234
Monday, November 7, 2011
HR reporting - defaulting value through programming
Ever wanted to put a default value into the HR reporting....
Now you can.
1. Run the program and press F1 to the defaulted field you want to initialise.
2. Under the abap coding "INITIALIZATION" copy the code below please modify base on your field name.
INITIALIZATION. "TO ADD IF THERE IS ANY TO INITIALIZE
PNPSTAT2-SIGN = 'I'.
PNPSTAT2-OPTION = 'EQ'.
PNPSTAT2-LOW = '0'. PNPSTAT2-HIGH = '0'. APPEND PNPSTAT2.
3. Activate and run the program! Walla Done...
Tuesday, November 1, 2011
SAP Remove Comma / Remove full stop
**********************************************************************
* FORM : remove_comma
* Created : 13.09.2011 18:33:22
**********************************************************************
FORM REMOVE_COMMA CHANGING $FIELD.
DATA : WA_INDEX(02) TYPE I.
DATA : F3(10) TYPE C.
F3 = $FIELD.
DO 10 TIMES.
IF F3+WA_INDEX(01) EQ ','.
F3+WA_INDEX(01) = ''.
ENDIF.
ADD 1 TO WA_INDEX.
ENDDO.
CONDENSE F3 NO-GAPS.
$FIELD = F3.
ENDFORM. " remove_comma
**********************************************************************
* FORM : remove_fullstop
* Created : 13.09.2011 18:33:22
**********************************************************************
FORM REMOVE_FULLSTOP CHANGING $FIELD.
DATA : WA_INDEX(02) TYPE I.
DATA : F3(10) TYPE C.
F3 = $FIELD.
DO 10 TIMES.
IF F3+WA_INDEX(01) EQ '.'.
F3+WA_INDEX(01) = ''.
ENDIF.
ADD 1 TO WA_INDEX.
ENDDO.
CONDENSE F3 NO-GAPS.
$FIELD = F3.
ENDFORM. " remove_fullstop
Thursday, October 13, 2011
Screen programming
DIAGRAM 1.0
DIAGRAM 2.0
Best practice to make the sy-ucomm to be fcode.
leave to screen 0. <--- to exit the current screen
leave program. <---- to exit the whole rogram
*** normally the program created in module pool (not executable) execute via TRANSACTION CODE
PROGRAM ZBC400_22_SCREEN.
DATA : FCODE TYPE SY-UCOMM.
tables : sflight.
*&---------------------------------------------------------------------*
*& Module SET_GUI_AND_TITLE OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE SET_GUI_AND_TITLE OUTPUT.
set PF-STATUS 'GUI100'.
set TITLEBAR 'TITLE' with sy-uname.
ENDMODULE. " SET_GUI_AND_TITLE OUTPUT
*&---------------------------------------------------------------------*
*& Module PROCESS_F_CODE INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE PROCESS_F_CODE INPUT.
CASE FCODE.
when 'ENTER'.
select single *
from sflight
WHERE carrid = sflight-carrid
and connid = sflight-connid
and fldate = sflight-fldate.
call screen 200.
WHEN 'GO_BACK'.
IF sy-dynnr = 200.
LEAVE to SCREEN 0.
else.
leave PROGRAM.
ENDIF.
WHEN 'SPECIAL'.
MESSAGE i010(ad) with 'special report'.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " PROCESS_F_CODE INPUT
DIAGRAM 3.0
Based on the above data.
1. create a program (module pool)
2. create screen100 *try not to use 1000 above cause it is standard
PROCESS BEFORE OUTPUT.
MODULE set_gui_and_title.
* MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
-- remember to use the Fcode in element list
3. create gui_status <--- this is for the screen
DIAGRAM 4.0
with this you can create icon and remember th fcode you can use the variable you created too
As for the application tool bar you can add your own ICON!! and apply the same FCODE too
Last but not least dont forget to create the title
DIAGRAM 5.0
**** CLICK on SCREEN then LAYOUT
here you can create your layout
remember for function aka push button remember to put the function code so that your system can manipulate it
remember what ever RED in colour when editing during layout its meaning is more towards error.
REMEMBER TO CALL YOUR PBO AND PAI MODULE INSIDE THE SCREEN!!! EXAMPLE DIAGRAM 3.0
* notice that we are all working in se80 that is why you can see the layout besides
* remember the coding above is sufficient for normal usage.
SAP sample coding of a almost complete understanding of the screen
*& Report ZDC_SALES_REP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZDC_SALES_REP no standard page heading
line-size 132
line-count 65(3).
data:
line_no(5) type n.
data:
v_matnr type vbap-matnr.
data:
it_salesdet type table of zdc_sales_doc,
wa_salesdet like line of it_salesdet.
* selection screen
parameters:
p_vkorg type vbak-vkorg obligatory.
select-options:
s_matnr for v_matnr.
parameters:
p_flag as checkbox.
initialization.
p_vkorg = 1000.
s_matnr-sign = 'I'.
s_matnr-option = 'BT'.
s_matnr-low = 'M-01'.
s_matnr-high = 'M-03'.
append s_matnr.
clear s_matnr.
s_matnr-sign = 'E'.
s_matnr-option = 'EQ'.
s_matnr-low = 'M-02'.
append s_matnr.
at selection-screen.
if p_flag = 'X' and s_matnr[] is not initial.
message e010(ad) with 'Error'.
endif.
start-of-selection.
" get data
select * into table it_salesdet
from zdc_sales_doc
where vkorg = p_vkorg
and matnr in s_matnr.
" display report
loop at it_salesdet into wa_salesdet.
add 1 to line_no.
write: / line_no,
wa_salesdet-vbeln color col_key,
wa_salesdet-posnr color col_key,
wa_salesdet-kunnr color col_positive,
wa_salesdet-netwr,
wa_salesdet-matnr,
wa_salesdet-ZMEng color col_total.
endloop.
end-of-selection.
top-of-page.
write: /80 'Page:', sy-pagno.
uline.
clear line_no.
end-of-page.
format color col_total.
write: /(132) '--Continued--' centered.
Wednesday, October 12, 2011
DATA DECLARATION SAP
*& Report ZBC400_22_ITAB
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZBC400_22_ITAB.
"BEST PRACTICE TO DECLARE TYPE FIRST
"THEN ONLY ASSIGN THE TYPE TO EITHER STRUCTURE OR TABLE
"TYPE TABLE OF <<<< KEY WORD TO CREATE AN INTERNAL TABLE
"THEN FOLLOWED BY
"LIKE LINE OF <<<< KEY WORD TO CREATE A WORK AREA / STRUCTURE FOR THE TABLE
*defination of internal table
*TYPES : TY_FLIGHT TYPE SFLIGHT.
TYPES :
BEGIN OF TY_FLIGHT. "this is to include a table structure
INCLUDE STRUCTURE SFLIGHT. "this is to include a table structure
TYPES : "this extra type is due to the table being inserted
F1 TYPE C LENGTH 4,
F2 TYPE C LENGTH 4,
F3 TYPE SFLIGHT-FLDATE,
END OF TY_FLIGHT.
DATA: IT_FLIGHT TYPE TABLE OF TY_FLIGHT, "[[[ THIS IS THE INTERNAL TABLE BEING CREATED ]]]
WA_FLIGHT LIKE LINE OF IT_FLIGHT. " WA_FLIGHT TYPE TY_FLIGHT
"< DONT FOLLOW THE COMMENT THOUGH SAME
START-OF-SELECTION.
SELECT * INTO TABLE IT_FLIGHT FROM SFLIGHT. "MODIFY
LOOP AT IT_FLIGHT INTO WA_FLIGHT. "MODIFY
WA_FLIGHT-PRICE = '88.88'. "CHANGING TO STRUCTURE ONLY "MODIFY
MODIFY IT_FLIGHT INDEX SY-TABIX FROM WA_FLIGHT. "MODIFY
"MODIFY
ENDLOOP.
DELETE IT_FLIGHT WHERE CARRID = 'LH'. "DELETE
"APPEND WORKS ONLY FOR STANDARD DATA
CLEAR WA_FLIGHT. "APPEND
WA_FLIGHT-CARRID = 'LH'. "APPEND
WA_FLIGHT-CONNID = '8888'. "APPEND
WA_FLIGHT-FLDATE = '20111231'. "APPEND
APPEND WA_FLIGHT TO IT_FLIGHT. "APPEND
CLEAR WA_FLIGHT. "CLEAR TO ENSURE THE WA IS CLEAN
READ TABLE IT_FLIGHT INTO WA_FLIGHT WITH KEY CARRID = 'JL'. "READ AND ASSIGN TO WA_FLIGHT
IF SY-SUBRC = 0 . "DISPLAYED ASSIGNED WA_FLIGHT
WRITE: / 'ROW NUMBER=', SY-TABIX, "DISPLAYED ASSIGNED WA_FLIGHT
WA_FLIGHT-CARRID, "DISPLAYED ASSIGNED WA_FLIGHT
WA_FLIGHT-CONNID, "DISPLAYED ASSIGNED WA_FLIGHT
WA_FLIGHT-FLDATE. "DISPLAYED ASSIGNED WA_FLIGHT
ENDIF. "DISPLAYED ASSIGNED WA_FLIGHT
CLEAR WA_FLIGHT. "CLEAR TO ENSURE THE WA IS CLEAN
SORT IT_FLIGHT BY CARRID. "SORT IT_FLIGHT BY CARRID
LOOP AT IT_FLIGHT INTO WA_FLIGHT FROM SY-TABIX. "LOOP AND ASSIGN TO WA_FLIGHT BY INDEX
IF WA_FLIGHT-CARRID = 'LH'. "CONDITIONAL WHERE EQUAL TO LH
WRITE: / 'ROW NUMBER=', SY-TABIX, "DISPLAYED ASSIGNED WA_FLIGHT
WA_FLIGHT-CARRID, "DISPLAYED ASSIGNED WA_FLIGHT
WA_FLIGHT-CONNID, "DISPLAYED ASSIGNED WA_FLIGHT
WA_FLIGHT-FLDATE. "DISPLAYED ASSIGNED WA_FLIGHT
ENDIF.
ENDLOOP.
CHECK 1 = 1.
Tuesday, October 4, 2011
Add Title(heading) to ALV Grid
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
i_save = 'X'
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
*-----------------------------------------------------------*
* Form TOP-OF-PAGE *
*-----------------------------------------------------------*
* ALV Report Header *
*-----------------------------------------------------------*
Form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.
* Title
wa_header-typ = 'H'.
wa_header-info = 'EKKO Table Report'.
append wa_header to t_header.
clear wa_header.
* Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays date
append wa_header to t_header.
clear: wa_header.
* Total No. of Records Selected
describe table it_ekko lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. of Records Selected: ' ld_linesc
into t_line separated by space.
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_header.
* i_logo = 'Z_LOGO'.
endform.
Tuesday, September 27, 2011
Function module HR_INFOTYPE_OPERATION
Function module HR_INFOTYPE_OPERATION to maintain SAP HR infotypes
The HR_INFOTYPE_OPERATION function module is used for the Maintenance of HR infotypes, such as inserting, changing, deleting data etc
Parameters Explained
Here is a list of the fm's parameters and how they are used, obviously not all parameters will be used depending on what function you are performing i.e. insert, change, delet etc
infty - Infotype being updated
objectid - object id from infotype
number - Personnel number
validityend - validity end date
validitybegin - validity begin date
record - infotype record values to be updated, inserted etc (will be structure of infortyoe you are updating)
recordnumber - sequence nunber from infotype record you are updating
Operation - describes what operation is to be performed
COP = Copy
DEL = Delete
DIS = Display
EDQ = Lock/unlock
INS = Create
LIS9 = Delimit
MOD = Change
INSS = Create for Actions is not converted to Change
nocommit - commit yes('X') / no(' ')
dialog_mode - dialog mode or not, default is '0'
CONSTANTS: change TYPE pspar-actio VALUE 'MOD'.
"This code is requred and locks the record ready for modification
CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
EXPORTING
number = p_pernr.
"loop at p0071 into p_p0071. "added to put code in context
validitybegin = p_record-begda.
validityend = p_record-endda.
p_record-endda = pn-begda - 1.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0071'
subtype = p_record-subty
objectid = P_record-objps
number = p_record-pernr "employeenumber
validityend = validityend
validitybegin = validitybegin
record = p_record
recordnumber = p_record-SEQNR
operation = change
nocommit = nocommit
dialog_mode = '0'
IMPORTING
return = return_struct
key = personaldatakey
EXCEPTIONS
OTHERS = 0.
"endloop.
"unlock record after modification
CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
EXPORTING
number = p_pernr.
CONSTANTS: insert TYPE pspar-actio VALUE 'INS'.
"This code is requred and locks the record ready for modification
CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
EXPORTING
number = p_pernr.
validitybegin = p_record-begda.
validityend = p_record-endda.
p_record-pernr = p_pernr
p_record-begda = pn-begda.
p_record-endda = validityend.
p_record-subty = p_SUBTY. "subtype of new entry
p_record-SCREF = p_SUBTY. "subtype of new entry
"plus populate any other fields you need to update
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0071'
subtype = p_record-subty
number = p_record-pernr "employeenumber
validityend = validityend
validitybegin = validitybegin
record = p_record
operation = insert
nocommit = nocommit
dialog_mode = '0'
IMPORTING
return = return_struct
key = personaldatakey
EXCEPTIONS
OTHERS = 0.
"unlock record after modification
CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
EXPORTING
number = p_pernr.
Also see BAPI_EMPLCOMM_CREATE for <a style="color: rgb(0, 0, 255); ">updating infotype 0105</a>
CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
EXPORTING
number = p_pernr.
p_record-subty = p_subtype. "subtype of new entry
p_record-pernr = p_pernr.
p_record-SEQNR = '000'.
validityend = '99991231'.
validitybegin = sy-datum.
p_record-begda = sy-datum.
p_record-endda = '99991231'.
p_record-usrid = 'TESTUSR'.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = '0105'
subtype = p_record-subty
objectid = P_record-objps
number = p_record-pernr "employeenumber
validityend = validityend
validitybegin = validitybegin
record = p_record
operation = 'INS'
nocommit = nocommit
dialog_mode = '0'
IMPORTING
return = return_struct
key = personaldatakey
EXCEPTIONS
OTHERS = 0.
if sy-subrc eq 0.
* success
endif.
CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
EXPORTING
number = p_pernr.
see BAPI_EMPLCOMM_CREATE if updating infotype 0105!!
Check out sap documentation and pattern details for function module hr_infotype_operation on website se80.co.uk
Source = http://www.sapdev.co.uk/fmodules/fms_HR_INFOTYPE_OPERATION.htm
Thursday, September 15, 2011
SAP HR Infotypes
SAP HR Infotypes
March 8, 2008 — harrypoe
Infotypes are also called information types and are pre-defined
templates to enter sensible related information for an employee or
applicant. for eg an address infotype would have fields like street
& house no, city, pin code.This infotype is unique and is
represented by an infotype number eg address has infotype no 0006. There
other infotypes like
- 0000 – Actions (to capture employee movement info in the orgnization)
- 0001 – Organizational Assignment (to capture employee positioning in the organization)
- 0002 – Personal Data
- 0006 – Address
- 0007 – Planned Working Time (Store planned working hours for the employee.)
- 0008 – Basic Salary
- 0009 – Bank Details
- 0014 – Recurring Payment
- 0015 – Additional payment
- 0016 – Contract Elements
- 2006 – Absence Quotas
The above infotypes together in the same sequence form a part of the
Hiring Action.To make you understand this better just try and recollect
the contents of your offer letter which your organization might have
given you. It would possibly read “We are delighted to offer you the
position (IT 0001) of ______. You will belong to ______ department (IT
0001). Your joining date will be ______(IT0000 or IT0041)and you will be
paid a salary of ______ (IT 0008). You will be paid monthly allowances
______ (IT 0008 or IT 0014) and we are also offering you a joining bonus
of ______ (IT 0015). You will be eligible for annual leave of ______
days (IT 2006) and sick leave of ______ (IT 2006).You will be on a
probation for six months from the date of joining (probation date &
confirmation date in IT0016). Your working hours will be from ____ hrs
to ____ hrs beginning Monday to Friday (IT 0007) and we look forward to
your presence on date ______(IT 0016)……
I hope this gives you some idea of what an infotype is.
This must have raised a question in many
minds that “Hey ! I got the offer during my recruitment so how come this
is being referred to after hiring?” Well thats simple – this is because
all your relevant data that was captured during recruitment was
transferred to the the master (called HR master data)during the hiring
process.
So how was it captured in recruitment?
Well, this was captured using recruitment actions like shortlist
candidate, for interview, make offer, offer accepted till you join the
organization and sign the joining letter when your data actually gets
transferred from the Recruitment module to the Personnel Administration
module. Again this data was captured in recruitment infotypes.
So we can now get an idea that in SAP HR ,all data is captured in infotypes.
Question and Answer
1.What are info types ?
Infotypes, known as information types are units of human resources
information formed by grouping related data fields together. These are
represented in the sap hr system by a unique 4 digit number eg. Personal
Data (0002), Address (0006) etc. All customer infotypes fall in the
number range from 9000 to 9999. The fields in the infotype would vary
based on the country grouping for eg if any employee belongs to country
grouping 10 than he would have the SSN no field in the Personal Data
infotype which would not be seen in same infotype for country grouping
99.
*Infotype numbering in SAP HR sub module
- 0000-0999 Personal Administration (HR Master Data)
- 1000-1999 PD Infotypes ( OM etc)
- 2000-2999 Time Infotypes
- 4000-4999 Recruitment Infotypes
So whenever you are searching for a customer defined infotype make
sure your search is restricted between 9000 -9999. The infotypes
relevant to retroactive accounting for payroll and time infotypes are
defined in the
IMG . Personnel Administration–>Customizing
Procedures–>Infotypes–>Define fields relevant for retroactive
accounting–> Retroactive accounting relevance for payroll and time
per IT
Under this node you define for each infotype the following:- 1.Check
if no organizational assignment exists for the employee in
IT0001-Organizational Assignment and throw an error, warning or no
message.
So whenever you are searching for a customer defined infotype make sure
your search is restricted between 9000 -9999.The infotypes relevant to
retroactive accounting for payroll and time infotypes are defined in the
IMG . Personnel Administration–>Customizing
Procedures–>Infotypes–>Define fields relevant for retroactive
accounting–> Retroactive accounting relevance for payroll and time
per IT
Under this node you define for each infotype the following:-
1.Check if no organizational assignment exists for the employee in
IT0001-Organizational Assignment and throw an error, warning or no
message.
2.Maintenance of this infotype is permissible, permissible with
warning, or not permissible after the employee has left the organization
(employee in inactive status).
3.Entries in payroll past are permissible, not permissible or check for entries in the payroll past are infotype specific.
4.Infotype is not relevant for retroactive accounting, change in the
infotype triggers retroactive accounting or retroactive accounting is
field-dependent according to table T588G where the fields whose change
in values should trigger retroactive accounting are defined. Hence you
can see the significance of field triggers in retroactive accounting
where retroactive accounting for a given infotype can be restricted to
changes in the past to certain fields of the infotype.
If there is case that we need to specify certain info types for certain countries only, below are the IMG path you can maintain:
SPRO–>Personnel Administration–>Customizing Procedures–> Assign infotypes to countries
Notes : CALL FUNCTION 'HR_READ_INFOTYPE'
*INFOTYPE 0000(ACTION) FROM DATE JOINED ONWARDS:-
CALL FUNCTION 'HR_READ_INFOTYPE'
EXPORTING
PERNR = PERNR-PERNR
INFTY = '0000'
BEGDA = '99991231'
ENDDA = '99991231'
TABLES
INFTY_TAB = I0000.
Tuesday, September 13, 2011
Notes : Sample Program. To read Unix file and perform BDC functions
INCLUDE ZPYLBMA128_VARIABLES.
"SELECTION SCREEN STARTS=========================
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN: SKIP 1.
PARAMETERS : DSN LIKE FILENAME-FILEEXTERN DEFAULT '/home/HRD/UL/test zakat.prn'.
PARAMETERS : MAPNAME DEFAULT SY-UNAME LIKE RPTAXXXX-MAP_NAME.
PARAMETERS : TEST_RUN TYPE C AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK B1.
"SELECTION SCREEN ENDS=========================
"INITIALIZATION STARTS=========================
INITIALIZATION.
DSN+6(3) = SY-SYSID.
REPNAME = SY-REPID.
"INITIALIZATION ENDS=========================
"AT SELECTION-SCREEN CHECKING STARTS=========================
AT SELECTION-SCREEN ON DSN.
CLEAR: IDSN.
TRY.
OPEN DATASET DSN FOR INPUT IN TEXT MODE ENCODING NON-UNICODE. "UNI-CONV
IF SY-SUBRC NE 0.
MESSAGE E899(5A) WITH 'Error in opening file:'(E01) DSN.
ENDIF.
CATCH CX_SY_FILE_OPEN.
CLOSE DATASET DSN.
OPEN DATASET DSN FOR INPUT IN TEXT MODE ENCODING NON-UNICODE. "UNI-CONV
IF SY-SUBRC NE 0.
MESSAGE E899(5A) WITH 'DATA DOES NOT EXITS:'(E01) DSN.
ENDIF.
ENDTRY.
AT SELECTION-SCREEN.
IF TEST_RUN NE 'X'.
CALL FUNCTION 'HR_MAPNAME_VERIFY'
EXPORTING
MAPNAME = MAPNAME
REPORTNAME = REPNAME
IMPORTING
MAPNAME = MAPNAME.
ENDIF.
"AT SELECTION-SCREEN CHECKING ENDS=========================
"START-OF-SELECTION=========================
START-OF-SELECTION.
"BDC OPEN GROUP
IF TEST_RUN NE 'X'.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = MAPNAME
KEEP = 'X'
USER = SY-UNAME.
ENDIF.
**TO READ DATA FROM UNIX FILE
DO.
READ DATASET DSN INTO IDSN.
IF SY-SUBRC EQ 0.
"WRITE IDSN-SUBTY LEFT-JUSTIFIED TO IDSN-SUBTY.
CONDENSE IDSN-SUBTY.
APPEND IDSN.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET DSN.
**TO PROCESS RECORD BY RECORD
DESCRIBE TABLE IDSN LINES ILINE.
CHECK ILINE > 0.
CLEAR: ITAB[], ERRTAB[]."errtab AND ERROR_FLAG ARE not used as there is no checking as yet!
LOOP AT IDSN.
CLEAR: ERRTAB.
MOVE: IDSN-PERNR TO PERNR1.
ADD 1 TO NUMREC. "Current Record (Row) Number
****To validate PF No & IC/Passport No
PERFORM VALIDATE_PERNR.
****To assign data to ITAB
IF ERROR_FLAG <> 'X'.
PERFORM ASSIGN_DATA.
ENDIF.
IF ERROR_FLAG <> 'X'.
IF TEST_RUN NE 'X'.
PERFORM FILL-DYNPROS.
ENDIF.
******HASHING FOR ACCEPTED RECORDS
ADD: 1 TO HEAD_COUNT,
PERNR1 TO HASH_PERNR.
APPEND ITAB.
ELSE.
******HASHING FOR REJECTED RECORDS
ADD: 1 TO HEAD_COUNT_RJ,
PERNR1 TO HASH_PERNR_RJ.
ENDIF.
****HASHING FOR ALL RECORDS
ADD: 1 TO HEAD_COUNT_TT,
PERNR1 TO HASH_PERNR_TT.
ENDLOOP.
"**Close BDC session
IF TEST_RUN NE 'X'.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
FORMAT COLOR COL_GROUP ON INTENSIFIED OFF.
WRITE:/ 'Batch input session', MAPNAME, 'created'.
FORMAT COLOR COL_GROUP OFF INTENSIFIED OFF.
SKIP 2.
ENDIF.
**PRINT HASHING SUMMARY
PERFORM PRINT_HASHING_SUMMARY.
WRITE:/ 'Record(s) with errors'.
WRITE:/ '---------------------'.
WRITE:/2(10) 'Record no.' , 14(60)'Error' , 76(10) 'PF No', 88(11) 'Member Type', 101(4) 'Wage Type',
107(10) 'Start Date' , 119(8) 'End Date' , 129(14) 'Membership Fee' ,
145(10) ' Number' , 157(20) 'Unit' , 179(9) 'Payee Key'.
WRITE:/2(10) '----------' , 14(60)'-----' , 76(10) '-----', 88(11) '-----------', 101(4) '---------',
107(10) '----------' , 119(8) '--------' , 129(14) '--------------' ,
145(10) ' ------' , 157(20) '----' , 179(9) '---------'.
LOOP AT ERRTAB.
WRITE:/2(10) ERRTAB-NUMREC , 14(60) ERRTAB-MESSG, 76(10) ERRTAB-PERNR, 88(11) ITAB-SUBTY, 101(4) ITAB-LGART,
107(10) ITAB-BEGDA, 119(8) ITAB-ENDDA, 129(14) ITAB-BETRG,
145(10) ITAB-ANZHL, 157(20) ITAB-ZEINH, 179(9) ITAB-EMFSL.
"itab-icnum, "itab-mtgln.
ENDLOOP.
END-OF-SELECTION.
"END-OF-SELECTION=========================
"======================REPORTS STARTS
**PRINT FOOTER
PERFORM WRITE_FOOTER.
********************* REPORT HEADER *******************************
TOP-OF-PAGE.
PAGENO = ' '.
PERFORM WRITE_HEADER USING '0001' 'M' SY-DATUM
SPACE '100213' ' HRIS, HRD' PAGENO.
SKIP 2.
INCLUDE ZPULRIA001.
"======================REPORTS ENDS
INCLUDE ZPYLBMA128_FORMS.
"--------------------------------------------------------------------------------------------------------------
"--------------------------------------------------------------------------------------------------------------
*&---------------------------------------------------------------------*
*& Include ZPYLBMA128_VARAIBLE
*&---------------------------------------------------------------------*
"DATA DECLARATION STARTS=========================
TABLES: PA0000, "HR Master Record: Infotype 0000 (Actions)
PA0001, "HR Master Record: Infotype 0001 (Org. Assignment)
PA0002, "HR Master Record: Infotype 0002 (Personal Data)
PA0185, "HR Master Record: Infotype 0185 [Identification] (SG)
T591S, "Subtype Texts (for Member Type Text)
T512T, "Wage Type Texts
T521B, "Payee Keys
T001, "Company Codes
SSCRFIELDS. "Fields on selection screens
** Table to hold all data row from flat file
DATA: BEGIN OF IDSN OCCURS 0,
PERNR(08) TYPE C, "PF No.
SUBTY(04) TYPE C, "Member Type (Sub-Type)
LGART(04) TYPE C, "Wage Type
BEGDA(08) TYPE C, "Start Date
ENDDA(08) TYPE C, "End Date
BETRG(13) TYPE C, "Membership Fee / Amount
ANZHL(10) TYPE C, "Number
ZEINH(20) TYPE C, "Unit
EMFSL(08) TYPE C, "Payee Key
" MTGLN(20) TYPE C, "Membership Number
" ICNUM(30) TYPE C, "New IC
END OF IDSN.
** Table to hold success data
DATA: BEGIN OF ITAB OCCURS 0,
PERNR LIKE P0000-PERNR, "PF No.
SUBTY LIKE RP50G-SUBTY, "Member Type (Sub-Type)
LGART LIKE P0057-LGART, "Wage Type
LGTXT LIKE T512T-LGTXT, "Wage Type Text*
BEGDA(10) TYPE C, "Start Date
ENDDA(10) TYPE C, "End Date
BETRG LIKE Q0057-BETRG, "Membership Fee
ANZHL LIKE P0057-ANZHL, "Number
ZEINH LIKE Q0057-EITXT, "Unit
EMFSL LIKE P0057-EMFSL, "Payee Key
EMFNA LIKE T521B-EMFNA, "Payee Key Text*
" STEXT LIKE T591S-STEXT, "Member Type Text
" MTGLN LIKE P0057-MTGLN, "Membership Number
" ICNUM LIKE P0185-ICNUM, "New IC
" CNAME LIKE P0002-CNAME, "Staff Name
END OF ITAB.
** Table to hold error data and error message
DATA: BEGIN OF ERRTAB OCCURS 0,
NUMREC TYPE I,
MESSG(60) TYPE C.
INCLUDE STRUCTURE ITAB.
DATA: END OF ERRTAB.
* Table for Batch Input
DATA: BEGIN OF BDCDATA OCCURS 20.
INCLUDE STRUCTURE BDCDATA.
DATA: END OF BDCDATA.
DATA: HEAD_COUNT TYPE I,
HEAD_COUNT_RJ TYPE I,
HEAD_COUNT_TT TYPE I,
HASH_PERNR TYPE P,
HASH_PERNR_RJ TYPE P,
HASH_PERNR_TT TYPE P.
DATA: ILINE TYPE I,
NUMREC TYPE I, "Record (Row) Number
ERROR_FLAG TYPE C, "Error Flag
" BK_ICNUM(30) TYPE C, "Unformatted IC Number
PAGENO(1) TYPE C, "Page Number (Report)
" TDATE(10) TYPE C, "To hold formatted date
PERNR1 LIKE P0000-PERNR. "Personnel Number
" ICTYPE LIKE P0185-ICTYP, "Document Type
" STARTDT LIKE SY-DATUM. "Hiring Start Date
DATA: REPNAME LIKE SY-REPID.
"DATA DECLARATION ENDS=========================
"--------------------------------------------------------------------------------------------------------------
"--------------------------------------------------------------------------------------------------------------
*&---------------------------------------------------------------------*
*& Include ZPYLBMA128_FORMS
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form assign_data
*&---------------------------------------------------------------------*
FORM ASSIGN_DATA.
CLEAR ERROR_FLAG.
MOVE-CORRESPONDING IDSN TO ITAB.
"**Retrieve Staff Name (Infotype 0002)
" SELECT SINGLE * FROM PA0002 WHERE PERNR EQ ITAB-PERNR.
" IF SY-SUBRC EQ 0.
" ITAB-CNAME = PA0002-CNAME. "Store Staff Name
" WRITE:/ PA0002-CNAME.
" ELSE.
" ERROR_FLAG = 'X'.
" MOVE-CORRESPONDING IDSN TO ERRTAB.
" ERRTAB-NUMREC = NUMREC.
" ERRTAB-MESSG = 'Staff Name not found'.
" APPEND ERRTAB. CLEAR ERRTAB.
" ENDIF.
"**Retrieve Member Type Text
" IF ERROR_FLAG NE 'X'.
" SELECT SINGLE * FROM T591S WHERE SPRSL EQ 'EN'
" AND INFTY = '0057'
" AND SUBTY = ITAB-SUBTY.
" IF SY-SUBRC EQ 0.
" ITAB-STEXT = T591S-STEXT.
" ELSE.
" ERROR_FLAG = 'X'.
" MOVE-CORRESPONDING IDSN TO ERRTAB.
" ERRTAB-NUMREC = NUMREC.
" ERRTAB-MESSG = 'Member Type not found'.
" APPEND ERRTAB. CLEAR ERRTAB.
" ENDIF.
" ENDIF.
"**Wage Type Text
" IF ERROR_FLAG NE 'X'.
" SELECT SINGLE * FROM T512T WHERE SPRSL EQ 'EN'
" AND MOLGA EQ '14'
" AND LGART = ITAB-LGART.
" IF SY-SUBRC EQ 0.
" ITAB-LGTXT = T512T-LGTXT.
" ELSE.
" ERROR_FLAG = 'X'.
" MOVE-CORRESPONDING IDSN TO ERRTAB.
" ERRTAB-NUMREC = NUMREC.
" ERRTAB-MESSG = 'Wage Type not found'.
" APPEND ERRTAB. CLEAR ERRTAB.
" ENDIF.
" ENDIF.
"**Payee Key Text
" IF ERROR_FLAG NE 'X'.
" SELECT * FROM T521B INTO TABLE WA_T521B WHERE EMFSL EQ ITAB-EMFSL.
" IF SY-SUBRC EQ 0.
" SORT WA_T521B BY ENDDA DESCENDING.
" LOOP AT WA_T521B.
" ITAB-EMFNA = WA_T521B-EMFNA. EXIT.
" ENDLOOP.
" ELSE.
" ERROR_FLAG = 'X'.
" MOVE-CORRESPONDING IDSN TO ERRTAB.
" ERRTAB-NUMREC = NUMREC.
" ERRTAB-MESSG = 'Wage Type not found'.
" APPEND ERRTAB. CLEAR ERRTAB.
" ENDIF.
" ENDIF.
ENDFORM. " assign_data
*&---------------------------------------------------------------------*
*& Form FILL-DYNPROS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FILL-DYNPROS .
PERFORM D1000.
PERFORM D2000.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'PA30'
TABLES
DYNPROTAB = BDCDATA.
ENDFORM. " FILL-DYNPROS
FORM D1000.
REFRESH BDCDATA.
CLEAR BDCDATA.
BDCDATA-PROGRAM = 'SAPMP50A'.
BDCDATA-DYNPRO = '1000'.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
**PF NO.
CLEAR BDCDATA.
BDCDATA-FNAM = 'RP50G-PERNR'.
BDCDATA-FVAL = IDSN-PERNR.
APPEND BDCDATA.
**INFOTYPE 0008
CLEAR BDCDATA.
BDCDATA-FNAM = 'RP50G-CHOIC'.
BDCDATA-FVAL = '0057'.
APPEND BDCDATA.
**SUBTYPE (Member Type)
CLEAR BDCDATA.
BDCDATA-FNAM = 'RP50G-SUBTY'.
BDCDATA-FVAL = IDSN-SUBTY.
APPEND BDCDATA.
CLEAR BDCDATA.
BDCDATA-FNAM = 'BDC_OKCODE'.
BDCDATA-FVAL = '=INS'.
APPEND BDCDATA.
ENDFORM. " d1000
*---------------------------------------------------------------------*
* FORM D2000
*---------------------------------------------------------------------*
FORM D2000.
CLEAR BDCDATA.
BDCDATA-PROGRAM = 'MP005700'.
BDCDATA-DYNPRO = '2000'.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
**START DATE
CLEAR BDCDATA.
BDCDATA-FNAM = 'P0057-BEGDA'.
"WRITE IDSN-BEGDA TO BDCDATA-FVAL DD/MM/YYYY.
CONCATENATE IDSN-BEGDA+6(2) '.' IDSN-BEGDA+4(2) '.' IDSN-BEGDA+0(4) INTO BDCDATA-FVAL.
APPEND BDCDATA.
**END DATE
CLEAR BDCDATA.
BDCDATA-FNAM = 'P0057-ENDDA'.
"WRITE IDSN-ENDDA TO BDCDATA-FVAL DD/MM/YYYY.
CONCATENATE IDSN-ENDDA+6(2) '.' IDSN-ENDDA+4(2) '.' IDSN-ENDDA+0(4) INTO BDCDATA-FVAL.
APPEND BDCDATA.
**Wage Type
CLEAR BDCDATA.
BDCDATA-FNAM = 'P0057-LGART'.
BDCDATA-FVAL = IDSN-LGART.
APPEND BDCDATA.
**Membership Fee
CLEAR BDCDATA.
BDCDATA-FNAM = 'Q0057-BETRG'.
BDCDATA-FVAL = IDSN-BETRG.
APPEND BDCDATA.
**Number
CLEAR BDCDATA.
BDCDATA-FNAM = 'P0057-ANZHL'.
BDCDATA-FVAL = IDSN-ANZHL.
APPEND BDCDATA.
**Unit
CLEAR BDCDATA.
BDCDATA-FNAM = 'Q0057-EITXT'.
BDCDATA-FVAL = IDSN-ZEINH.
APPEND BDCDATA.
**Payee Key
CLEAR BDCDATA.
BDCDATA-FNAM = 'P0057-EMFSL'.
BDCDATA-FVAL = IDSN-EMFSL.
APPEND BDCDATA.
"**Membership Number
" CLEAR BDCDATA.
" BDCDATA-FNAM = 'P0057-MTGLN'.
" BDCDATA-FVAL = IDSN-MTGLN.
" APPEND BDCDATA.
CLEAR BDCDATA.
BDCDATA-FNAM = 'BDC_OKCODE'.
BDCDATA-FVAL = '=UPD'.
APPEND BDCDATA.
ENDFORM. " d2000
*&---------------------------------------------------------------------*
*& Form print_hashing_summary
*&---------------------------------------------------------------------*
FORM PRINT_HASHING_SUMMARY.
SKIP 3.
WRITE: /20 'Accepted Records' COLOR COL_TOTAL,
40 'Rejected Records' COLOR COL_TOTAL,
60 ' Total Records' COLOR COL_TOTAL.
WRITE: /20 '----------------', 40 '----------------',
60 '----------------'.
WRITE: /02 'Head Count :',
20(13) HEAD_COUNT, 40(13) HEAD_COUNT_RJ,
60(13) HEAD_COUNT_TT.
WRITE: /02 'Hash Pernr :',
20(13) HASH_PERNR, 40(13) HASH_PERNR_RJ,
60(13) HASH_PERNR_TT.
SKIP 2.
ENDFORM. " print_hashing_summary
*&---------------------------------------------------------------------*
*& Form validate_pernr
*&---------------------------------------------------------------------*
FORM VALIDATE_PERNR.
DATA: RETCD, RETCD1.
ERROR_FLAG = SPACE.
**CHECK PERNR - PERSONNEL NUMBER
PERFORM CHECK_PERNR USING PERNR1 RETCD.
IF RETCD NE 0.
ERROR_FLAG = 'X'.
MOVE-CORRESPONDING IDSN TO ERRTAB.
ERRTAB-NUMREC = NUMREC.
ERRTAB-MESSG = 'PF number not found'.
APPEND ERRTAB. CLEAR ERRTAB.
ENDIF.
CHECK RETCD EQ 0.
" IF IDSN-ICNUM+6(1) EQ '-' AND IDSN-ICNUM+9(1) EQ '-'.
"****Subtype 'IC'
" ICTYPE = '01'.
" CONCATENATE IDSN-ICNUM+0(6) IDSN-ICNUM+7(2) IDSN-ICNUM+10(4)
" INTO BK_ICNUM.
" ELSE.
"****Subtype 'Passport'
" ICTYPE = '02'.
" MOVE IDSN-ICNUM TO BK_ICNUM.
" ENDIF.
" PERFORM VERIFY_DOCID USING PERNR1 ICTYPE BK_ICNUM RETCD1.
" IF RETCD1 NE 0.
" ERROR_FLAG = 'X'.
" MOVE-CORRESPONDING IDSN TO ERRTAB.
" ERRTAB-NUMREC = NUMREC.
" ERRTAB-MESSG = 'IC/Passport No. not found'.
" APPEND ERRTAB. CLEAR ERRTAB.
" ENDIF.
ENDFORM. " validate_pernr
FORM CHECK_PERNR USING PPERNR PRETCD.
**Check from Infortype 0000 (Action)
SELECT * FROM PA0000 WHERE PERNR EQ PPERNR. EXIT. ENDSELECT.
PRETCD = SY-SUBRC.
IF SY-SUBRC NE 0. EXIT. ENDIF.
**Check from Infotype 0001 (Organizational Assignment)
SELECT * FROM PA0001 WHERE PERNR EQ PPERNR. EXIT. ENDSELECT.
PRETCD = SY-SUBRC.
ENDFORM.
"--------------------------------------------------------------------------------------------------------------
"--------------------------------------------------------------------------------------------------------------
***INCLUDE ZPULRIA001 .
*----------------------------------------------------------------------
* Report header
*----------------------------------------------------------------------
FORM WRITE_HEADER USING VALUE(RBUKRS) VALUE(RTYPE) VALUE(RDATE)
VALUE(RTITL2) VALUE(RBRHCD) VALUE(RBRH)
RINDC.
DATA: CBUTXT(25), TITLEN TYPE I, OUTDATE(10), REPDATE(10).
DATA: BUKLEN TYPE I.
STATICS: CPAGNO(4).
IF RINDC = 'X'. CPAGNO = 0. RINDC = SPACE. ENDIF.
ADD 1 TO CPAGNO.
IF RBUKRS = 'G'.
CBUTXT = 'MAYBANK GROUP'.
ELSE.
PERFORM RE001 USING RBUKRS CBUTXT.
ENDIF.
CALL FUNCTION 'Z_CONV_DATE_TO_SLASH_FMT'
EXPORTING
IDATE = SY-DATUM
INDICATOR = '1'
IMPORTING
ODATE = OUTDATE.
CALL FUNCTION 'Z_CONV_DATE_TO_SLASH_FMT'
EXPORTING
IDATE = RDATE
INDICATOR = '1'
IMPORTING
ODATE = REPDATE.
* Line 1
TRANSLATE CBUTXT TO UPPER CASE.
TRANSLATE SY-TITLE TO UPPER CASE.
BUKLEN = STRLEN( CBUTXT ). BUKLEN = 32 - BUKLEN. BUKLEN = BUKLEN / 2.
TITLEN = STRLEN( SY-TITLE ). TITLEN = 69 - TITLEN.TITLEN = TITLEN / 2.
TITLEN = TITLEN + 34 - BUKLEN.
WRITE:/1 '1',2 CBUTXT.
WRITE AT TITLEN SY-TITLE.
* cpagno = sy-pagno. shift cpagno right deleting trailing space.
SHIFT CPAGNO RIGHT DELETING TRAILING SPACE.
WRITE:100 'RUN DATE :', 112 OUTDATE, 122 'PAGE:', 127 CPAGNO.
* Line 2
IF RTYPE = 'B'.
WRITE:/2 'BRANCH', 9 RBRHCD, 15 RBRH.
ELSEIF RTYPE = 'P'.
WRITE:/2 'P.AREA' , 9 RBRHCD, 17 RBRH.
ELSEIF RTYPE = 'R'.
WRITE:/2 'REGION' , 9 RBRHCD, 17 RBRH.
ELSEIF RTYPE = 'N'. WRITE /2 ' '. "Blank - don't have to display
ELSE.
WRITE:/2 'DEPT' , 9 RBRHCD, 17 RBRH.
ENDIF.
IF NOT RTITL2 IS INITIAL.
BUKLEN = STRLEN( RBRH ). BUKLEN = 36 - BUKLEN. BUKLEN = BUKLEN / 2.
TITLEN = STRLEN( RTITL2 ). TITLEN = 52 - TITLEN.TITLEN = TITLEN / 2.
TITLEN = TITLEN + 50 - BUKLEN.
WRITE AT TITLEN RTITL2.
WRITE: 100 'REPORT NO :', 115 SY-REPID.
WRITE:/51 'REPORT DATE :', 65 REPDATE.
ELSE.
WRITE: 51 'REPORT DATE :', 65 REPDATE.
WRITE: 100 'REPORT NO :', 115 SY-REPID.
ENDIF.
ENDFORM.
*----------------------------------------------------------------------
* Read T001 to get company description
*----------------------------------------------------------------------
FORM RE001 USING VALUE(TBUKRS) TBUTXT.
CLEAR: TBUTXT, T001.
SELECT SINGLE * FROM T001 WHERE BUKRS EQ TBUKRS.
IF SY-SUBRC EQ 0. TBUTXT = T001-BUTXT. ENDIF.
ENDFORM.
*----------------------------------------------------------------------
* Report footer
*----------------------------------------------------------------------
FORM WRITE_FOOTER.
SKIP 2.
WRITE:/2 '*** END OF REPORT ***'.
ENDFORM.