Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

upload data

Former Member
0 Likes
741

Hi all,

can some one provide me a code sample for uploading data to all infotypes (a generic one ) using gui_upload and hr_infotype_operation fm.

regards,

ashok

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
610

hi,

this is a sample code for uploading infotype 185.

REPORT zhrpyn_in_0185

NO STANDARD PAGE HEADING LINE-SIZE 255 MESSAGE-ID zhr.

INCLUDE zhrpyr_in_screen.

*INTERNAL TABLE FOR INSERTING DATA INTO THE BDC SESSION

DATA: BEGIN OF i_record OCCURS 0,

  • data element: PERNR_D

  • pernr(8),

pernr LIKE pa0185-pernr,

  • data element: SUBTY

subty(002),

  • data element: BEGDA

begda(010),

  • data element: ENDDA

endda(010),

  • data element: IDNUM

icnum(030),

  • data element: FLAG

flag(1),

begindate TYPE d,

END OF i_record.

*************************************************************************

  • changed on 24.02.2006 CR::PADK904014

*************************************************************************

*Internal table for getting the files from the directory

DATA: i_file_list TYPE epsfili OCCURS 0 WITH HEADER LINE.

  • Internal Table for getting required files names from the retrieved flat file list

DATA: BEGIN OF lt_final_list OCCURS 0,

date TYPE date, "sy-datum,

time LIKE sy-timlo,

name(80),

name1(80),

fullpath(85),

END OF lt_final_list.

  • Internal table to store Error messages

DATA: BEGIN OF it_error_msg OCCURS 0,

pernr(10) TYPE c,

msg(255) TYPE c,

END OF it_error_msg.

  • Internal table to store payroll area information

DATA :BEGIN OF it_pa0001 OCCURS 0,

pernr TYPE pa0001-pernr,

abkrs TYPE pa0001-abkrs,

bukrs TYPE pa0001-bukrs,

END OF it_pa0001.

  • Internal table to store hiring action data.

DATA: BEGIN OF it_pa0000 OCCURS 0,

pernr LIKE pa0000-pernr,

massn LIKE pa0000-massn,

stat2 LIKE pa0000-stat2,

END OF it_pa0000.

  • Internal table to Error data

DATA: BEGIN OF it_error_data OCCURS 0,

row(600),

END OF it_error_data.

*Internal table to store error files

DATA : BEGIN OF it_temp OCCURS 0,

name(85),

END OF it_temp.

*Internal table for storing the incorrect personnel number

DATA :BEGIN OF i_pernr OCCURS 0,

pernr(5000),

END OF i_pernr.

*Internal Table for Upload of records from flat file.

DATA : BEGIN OF i_copy OCCURS 0,

row(600) TYPE c,

END OF i_copy.

DATA : BEGIN OF i_table OCCURS 0,

row(600) TYPE c,

END OF i_table.

*Standard Table used for Batch Input Processing.

DATA : BEGIN OF bdcdata OCCURS 0.

INCLUDE STRUCTURE bdcdata.

DATA : END OF bdcdata.

  • Variables.

DATA : v_len TYPE i,

v_head(1) TYPE c,

v_date TYPE string,

v_nor(10) TYPE c,

v_space TYPE string,

v_thead(1) TYPE c,

v_tdate TYPE string,

v_tnor(10) TYPE c,

v_tspace TYPE string,

v_abkrs(2),

v_begda(8),

v_count(10) TYPE n,

v_pernr_1(8),

v_date_c TYPE d,

v_begindate TYPE sy-datum,

v_qid LIKE apqi-qid, " to store the QID

v_f_n TYPE string,

v_f_e TYPE string,

v_filename TYPE rlgrap-filename, " for download the error pernr

v_filename1 TYPE rlgrap-filename, " for download the error pernr

v_wa_zqid_filename LIKE zqid_filename,

v_panflag,

v_index TYPE i.

*Constants

DATA : c_session TYPE d0100-mapn VALUE 'ZHRPY_185',

c_tcode LIKE tstc-tcode VALUE 'PA30',

c_infotype(4) VALUE '0185'.

START-OF-SELECTION.

*Function for uploading the files from the application server

CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'

EXPORTING

dir_name = '\lgcsap_IN\IT0185'

TABLES

dir_list = i_file_list

EXCEPTIONS

invalid_eps_subdir = 1

sapgparam_failed = 2

build_directory_failed = 3

no_authorization = 4

read_directory_failed = 5

too_many_read_errors = 6

empty_directory_list = 7

OTHERS = 8.

  • Return Code check

IF sy-subrc <> 0.

MESSAGE e000 WITH 'Location Invalid'.

STOP.

ENDIF.

  • Get all the file names based on timstamp.

LOOP AT i_file_list.

*Copy file name into the final internal table

MOVE i_file_list-name TO lt_final_list-name.

  • Assuming files are txt

SEARCH i_file_list-name FOR '.txt'.

*Return Code Check

IF sy-subrc = 0.

  • Search for the file name

SEARCH i_file_list-name FOR 'LGCSAPINPIT0185'

STARTING AT 1

ENDING AT 15.

  • Return code Check

IF sy-subrc <> 0.

CONCATENATE '\lgcsap_IN\IT0185\' i_file_list-name INTO it_temp-name.

APPEND it_temp.

*Displaying the error message

  • MESSAGE e000 WITH 'File Not Found'.

*

ELSE.

*code to change date format from ddmmyy to yymmdd for sorting

v_date_c = i_file_list-name+15(8).

CONCATENATE v_date_c4(4) v_date_c2(2) v_date_c+0(2) INTO

lt_final_list-date.

  • Getting the time date value

lt_final_list-time = i_file_list-name+23(6).

  • Concatenate the text to get the input file name.

CONCATENATE '\lgcsap_IN\IT0185' lt_final_list-name INTO

lt_final_list-fullpath SEPARATED BY '\'.

  • Concatenate the text to get the output file name.

CONCATENATE '\lgcsapREAD_IN\IT0185_READ' lt_final_list-name

INTO lt_final_list-name1 SEPARATED BY '\'.

  • Append the list.

APPEND lt_final_list.

ENDIF.

ENDIF.

ENDLOOP.

IF lt_final_list[] IS INITIAL.

MESSAGE i000 WITH text-012.

LEAVE LIST-PROCESSING.

ELSE.

  • sort the table by Date and Time.

SORT lt_final_list BY date ASCENDING time ASCENDING.

  • Get all files selected

LOOP AT lt_final_list.

  • Initialize the table

CLEAR: i_copy,

i_record,

v_filename,

v_filename1,

v_f_n,

v_f_e.

REFRESH: i_copy,i_record.

SPLIT lt_final_list-name AT '.' INTO v_f_n

v_f_e.

CONCATENATE v_f_n '_ERR.txt' INTO v_filename.

v_filename1 = lt_final_list-name.

  • For uploading the flat file from application server.

OPEN DATASET lt_final_list-fullpath FOR INPUT IN TEXT MODE ENCODING DEFAULT.

  • Return code Check

IF sy-subrc <> 0.

*Display the error message that file cannot be opened.

MESSAGE e000 WITH 'File cannot be opened'.

STOP.

ELSE.

DO.

  • Read The records from the flat file into internal table

READ DATASET lt_final_list-fullpath INTO i_copy.

  • Return Code Check.

IF sy-subrc NE 0.

EXIT.

ELSE.

*Append the records

APPEND i_copy.

ENDIF.

ENDDO.

ENDIF.

  • Close the dataset after reading the records.

CLOSE DATASET lt_final_list-fullpath.

  • Moving the flat file into another folder

OPEN DATASET lt_final_list-name1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

  • Return Code Check.

IF sy-subrc = 0.

*looping at the internal table

LOOP AT i_copy.

  • Transfer the file.

TRANSFER i_copy TO lt_final_list-name1.

ENDLOOP.

ENDIF.

  • Close the dataset after writing the records.

CLOSE DATASET lt_final_list-name1.

*Return code check

IF sy-subrc = 0 .

  • To get the number of lines in the internal table

DESCRIBE TABLE i_copy LINES v_len.

  • To separate the data into Header, Actual data and Trailer records.

LOOP AT i_copy.

*To separate the header record.

IF sy-tabix = 1 AND i_copy-row+0(1) = 'H'.

  • Split the header data into respective fields.

SPLIT i_copy AT '|' INTO v_head

v_date

v_nor

v_space.

  • Display Header Records

WRITE: 'HEADER RECORDS'.

WRITE: / v_head,

v_date,

v_nor.

  • To separate the trailer records

ELSEIF sy-tabix = v_len AND i_copy-row+0(1) = 'T'.

  • Split the Trailer data into respective fields.

SPLIT i_copy AT '|' INTO v_thead

v_tdate

v_tnor

v_tspace.

  • Display Trailer Records

WRITE: / 'TRAILER RECORDS'.

WRITE: / v_thead,

v_tdate,

v_tnor.

  • To separate the actual records.

ELSE.

  • Split the Actual data into respective fields.

SPLIT i_copy AT '|' INTO i_record-pernr

i_record-begda

i_record-endda

i_record-subty

i_record-icnum.

  • Display Records

WRITE: / i_record-pernr,

i_record-begda,

i_record-endda,

i_record-subty,

i_record-icnum.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = i_record-pernr

IMPORTING

output = i_record-pernr.

CONCATENATE i_record-begda+6(4)

i_record-begda+3(2)

i_record-begda+0(2)

INTO i_record-begindate .

  • Append the records

APPEND i_record.

ENDIF.

ENDLOOP.

ENDIF.

*Check if the number of rows in header & trailer r same.

IF v_nor <> v_tnor .

*Display error message.

MESSAGE e000 WITH text-000.

ENDIF.

IF i_record[] IS NOT INITIAL.

*For all the records read from the application server file, get their payroll area from table PA0001.

SELECT pernr abkrs bukrs INTO TABLE it_pa0001

FROM pa0001

FOR ALL ENTRIES IN i_record

WHERE pernr = i_record-pernr

AND begda LE i_record-begindate

AND endda GE i_record-begindate .

IF sy-subrc = 0.

SORT it_pa0001 BY pernr.

ENDIF.

*For all the records read from the application server file, get their hiring information

SELECT pernr massn stat2 INTO TABLE it_pa0000

FROM pa0000

FOR ALL ENTRIES IN i_record

WHERE pernr = i_record-pernr

AND stat2 = '3'

AND massn = '01'.

IF sy-subrc = 0.

SORT it_pa0000 BY pernr.

ENDIF.

ENDIF.

IF i_record[] IS NOT INITIAL.

*Open a new session.

PERFORM open_group.

*loop at the internal table i_record

LOOP AT i_record.

v_index = sy-tabix.

READ TABLE it_pa0000 WITH KEY pernr = i_record-pernr BINARY SEARCH.

*Check if the employee is hired and is active.

IF sy-subrc NE 0.

*Get the personnel number into internal table i_pernr

it_error_msg-pernr = i_record-pernr.

it_error_msg-msg = 'Employee not hired or is in inactive status'.

CONCATENATE i_record-pernr

i_record-begda

i_record-endda

i_record-subty

i_record-icnum

INTO it_error_data-row

SEPARATED BY '|'.

*append the record

APPEND it_error_msg.

CLEAR it_error_msg.

APPEND it_error_data.

CLEAR it_error_data.

DELETE i_record WHERE pernr = i_record-pernr .

CONTINUE.

ENDIF.

READ TABLE it_pa0001 WITH KEY pernr = i_record-pernr BINARY SEARCH.

IF sy-subrc EQ 0.

*Check if the payroll area belongs to india

  • IF it_pa0001-abkrs NE 'TC' OR it_pa0001-bukrs NE 'TCSI'.

IF NOT ( it_pa0001-bukrs IN com_code ) .

*Get the personnel number into internal table i_pernr

it_error_msg-pernr = i_record-pernr.

it_error_msg-msg = 'Invalid Payroll Area.'.

CONCATENATE i_record-pernr

i_record-begda

i_record-endda

i_record-subty

i_record-icnum

INTO it_error_data-row

SEPARATED BY '|'.

*append the record

APPEND it_error_msg.

CLEAR it_error_msg.

APPEND it_error_data.

CLEAR it_error_data.

DELETE i_record WHERE pernr = i_record-pernr.

CONTINUE.

ENDIF.

ENDIF.

IF i_record-subty = '02'.

PERFORM pan_validation USING i_record-icnum CHANGING v_panflag.

IF v_panflag = 'Y'.

*Get the personnel number into internal table i_pernr

it_error_msg-pernr = i_record-pernr.

it_error_msg-msg = 'Invalid PAN NO.'.

CONCATENATE i_record-pernr

i_record-begda

i_record-endda

i_record-subty

i_record-icnum

INTO it_error_data-row

SEPARATED BY '|'.

*append the record

APPEND it_error_msg.

CLEAR it_error_msg.

APPEND it_error_data.

CLEAR it_error_data.

DELETE i_record INDEX v_index.

CONTINUE.

ENDIF.

ENDIF.

PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=INS'.

*INSERTING PERSONNEL NUMBER

PERFORM bdc_field USING 'RP50G-PERNR'

i_record-pernr.

PERFORM bdc_field USING 'BDC_CURSOR'

'RP50G-SUBTY'.

*INSERTING INFOTYPE

PERFORM bdc_field USING 'RP50G-CHOIC'

c_infotype.

*INSERTING SUBTYPE

PERFORM bdc_field USING 'RP50G-SUBTY'

i_record-subty.

*FOR SA

IF i_record-subty = '01'.

PERFORM bdc_dynpro USING 'MP018500' '2040'.

PERFORM bdc_field USING 'BDC_CURSOR'

'P0185-AUTH1'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=UPD'.

*INSERTING BEGIN DATE

PERFORM bdc_field USING 'P0185-BEGDA'

i_record-begda.

*INSERTING END DATE

PERFORM bdc_field USING 'P0185-ENDDA'

i_record-endda.

*INSERTING THE SA IDENTITY NO

PERFORM bdc_field USING 'P0185-ICNUM'

i_record-icnum.

*INSERTING THE SA ID

PERFORM bdc_field USING 'P0185-AUTH1'

'SATC'.

*FOR PF

ELSEIF i_record-subty = '02'.

PERFORM bdc_dynpro USING 'MP018500' '2240'.

PERFORM bdc_field USING 'BDC_CURSOR'

'P0185-ICNUM'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=UPD'.

*INSERTING BEGIN DATE

PERFORM bdc_field USING 'P0185-BEGDA'

i_record-begda.

*INSERTING END DATE

PERFORM bdc_field USING 'P0185-ENDDA'

i_record-endda.

*INSERTING THE PF IDENTITY NO

PERFORM bdc_field USING 'P0185-ICNUM'

i_record-icnum.

*FOR GRATUITY

ELSEIF i_record-subty = '03'.

PERFORM bdc_dynpro USING 'MP018500' '2340'.

PERFORM bdc_field USING 'BDC_CURSOR'

'P0185-AUTH1'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=UPD'.

*INSERTING BEGIN DATE

PERFORM bdc_field USING 'P0185-BEGDA'

i_record-begda.

*INSERTING END DATE

PERFORM bdc_field USING 'P0185-ENDDA'

i_record-endda.

*INSERTING THE GRATUITY IDENTITY NO

PERFORM bdc_field USING 'P0185-ICNUM'

i_record-icnum.

*INSERTING THE GRATUITY ID

PERFORM bdc_field USING 'P0185-AUTH1'

'GRTC'.

ENDIF.

  • Insert the data from bdcdata table to the session

PERFORM bdc_insert.

  • Initialize the internal table.

REFRESH bdcdata.

CLEAR : i_record.

CLEAR : v_index .

ENDLOOP.

PERFORM close_group.

PERFORM submit_session.

ENDIF.

IF v_qid IS INITIAL.

v_qid = '9999999999'.

ENDIF.

*display the message that the session is created

MOVE: v_qid TO v_wa_zqid_filename-qid,

lt_final_list-name TO v_wa_zqid_filename-filename,

lt_final_list-fullpath TO v_wa_zqid_filename-fullpath,

lt_final_list-name1 TO v_wa_zqid_filename-readpath,

  • 'TC' TO v_wa_zqid_filename-abkrs.

com_code TO v_wa_zqid_filename-bukrs.

INSERT INTO zqid_filename VALUES v_wa_zqid_filename.

  • Delete the dataset that has been read.

DELETE DATASET lt_final_list-fullpath.

CONCATENATE '\saplgc_IN\ERROR_LOG\' v_filename INTO v_filename.

CONCATENATE '\saplgc_IN\ERROR_LOG\' v_filename1 INTO v_filename1.

IF it_error_msg[] IS NOT INITIAL.

  • Moving the error log data into application server location

OPEN DATASET v_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

  • Return Code Check.

IF sy-subrc = 0.

  • Transfer the file.

LOOP AT it_error_msg.

TRANSFER it_error_msg TO v_filename.

ENDLOOP.

ENDIF.

  • Close the dataset after writing the records.

CLOSE DATASET v_filename.

  • Moving the error data into application server location

OPEN DATASET v_filename1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

  • Return Code Check.

IF sy-subrc = 0.

  • Transfer the file.

LOOP AT it_error_data.

TRANSFER it_error_data TO v_filename1.

ENDLOOP.

ENDIF.

  • Close the dataset after writing the records.

CLOSE DATASET v_filename1.

ENDIF.

REFRESH : it_error_data,

it_error_msg.

CLEAR: v_qid,

lt_final_list-name,

lt_final_list-fullpath,

lt_final_list-name1.

ENDLOOP.

ENDIF.

IF NOT it_temp[] IS INITIAL.

LOOP AT it_temp.

*delete the dataset that has been read.

DELETE DATASET it_temp-name.

MESSAGE e000 WITH text-013.

ENDLOOP .

ENDIF.

  • OPEN DATASET i_final_list-name1 FOR OUTPUT IN TEXT MODE ENCODING

*DEFAULT.

*

    • Return Code Check.

  • IF sy-subrc = 0.

*

**looping at the internal table

  • LOOP AT i_copy.

*

    • Transfer the file.

  • TRANSFER i_copy TO i_final_list-name1.

  • ENDLOOP.

  • ENDIF.

*

    • Close the dataset after writing the records.

  • CLOSE DATASET i_final_list-name1.

*

    • Delete the dataset that has been read.

  • DELETE DATASET i_final_list-fullpath.

*

  • ENDLOOP.

**Get the name of the file into a variable

  • concatenate 'C:\Error_Pernr\IT0041_185ERR' sy-datum sy-UZEIT '.txt'

*into

  • v_filename.

*

**Download the mismatching pernr into a separate flat file.

  • CALL FUNCTION 'GUI_DOWNLOAD'

  • EXPORTING

  • FILENAME = v_filename

  • TABLES

  • DATA_TAB = i_pernr

  • 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.

*

**Return code check

  • IF SY-SUBRC <> 0.

  • message e000 with text-005.

  • ENDIF.

*

**Get the number of rows in the internal table i_pernr

  • describe table i_pernr lines v_count.

*

**Check for the number of rows

  • if v_count > 0.

*

**Display message

  • message i000 with v_count text-006.

  • endif.

*

**Display message that session has been created successfully.

  • MESSAGE s000 WITH text-004 c_sesSION .

*----


  • Subroutine for opening a new session.

*----


*ENDLOOP.

**************************************************************************

  • Form open_group

**************************************************************************

  • text

**************************************************************************

FORM open_group.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

client = sy-mandt

group = c_session

keep = 'X'

user = sy-uname

IMPORTING

qid = v_qid

EXCEPTIONS

client_invalid = 1

destination_invalid = 2

group_invalid = 3

group_is_locked = 4

holddate_invalid = 5

internal_error = 6

queue_error = 7

running = 8

system_lock_error = 9

user_invalid = 10

OTHERS = 11.

  • Return Code Check.

IF sy-subrc NE 0.

WRITE: / 'UNSUCESSFUL'.

ENDIF.

ENDFORM. "open_group

*

**************************************************************************

  • 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

**************************************************************************

  • Form BDC_INSERT

**************************************************************************

  • Subroutine to insert the Internal Table BDCDATA into the session

**************************************************************************

FORM bdc_insert.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

tcode = c_tcode "PA30

TABLES

dynprotab = bdcdata

EXCEPTIONS

internal_error = 1

not_open = 2

queue_error = 3

tcode_invalid = 4

printing_invalid = 5

posting_invalid = 6

OTHERS = 7.

ENDFORM. "BDC_INSERT

**************************************************************************

  • Form CLOSE_GROUP

**************************************************************************

  • Subroutine for closing a session

**************************************************************************

FORM close_group .

CALL FUNCTION 'BDC_CLOSE_GROUP'

EXCEPTIONS

not_open = 1

queue_error = 2

OTHERS = 3.

  • Return Code Check.

IF sy-subrc NE 0.

WRITE: 'UNSUCCESSFUL'.

STOP.

ENDIF.

ENDFORM. " CLOSE_GROUP

************************************************************************

  • END OF PROGRAM

************************************************************************

&----


*& Form pan_validation

&----


  • text

----


  • -->P_I_RECORD_ICNUM text

----


FORM pan_validation USING p_i_record_icnum

CHANGING v_panflag.

DATA : v_panno TYPE string ,

v_panlen TYPE i,

v_pan_alpha(6),

v_pan_num(4).

DATA : c_alpha TYPE string VALUE 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',

c_numeric TYPE string VALUE '0123456789'.

CLEAR : v_panflag.

*Get the PAN No into a string variable

v_panno = i_record-icnum.

*Condense the string v_panno

CONDENSE v_panno.

*Get the PAN NO length into a variable

v_panlen = STRLEN( v_panno ).

*If the PAN No length is not 10

IF v_panlen NE 10.

*Set the PAN flag

v_panflag = 'Y'.

ELSE.

*Get the First five alphabets into v_pan_alpha

v_pan_alpha = v_panno+0(5).

*Get the last alphabet into v_pan_alpha

v_pan_alpha5(1) = v_panno9(1).

*Get the numbers into v_pan_num

v_pan_num = v_panno+5(4).

*IF v_pan_alpha contains literals other than alphabet

IF v_pan_alpha CN c_alpha.

*Set the PAN flag

v_panflag = 'Y'.

*IF v_pan_num contains non-numeric contants .

ELSEIF v_pan_num CN c_numeric.

*Set the PAN flag

v_panflag = 'Y'.

ENDIF.

ENDIF.

CLEAR : v_panno , v_panlen , v_pan_alpha , v_pan_num.

ENDFORM. " pan_validation

&----


*& Form submit_session

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM submit_session .

DATA: v_date(10).

CONCATENATE sy-datum6(2) '.' sy-datum4(2) '.' sy-datum+0(4)

INTO v_date.

SUBMIT zrsbdcsub USING SELECTION-SCREEN '1000'

WITH mappe EQ c_session

WITH von EQ sy-datum

  • WITH bis EQ v_date

WITH logall EQ 'X'

WITH z_verarb EQ 'X'

WITH fehler EQ ' '

AND RETURN.

ENDFORM. " submit_session

Reward points if helpful,

Regards,

Sumanjeet.

1 REPLY 1
Read only

Former Member
0 Likes
611

hi,

this is a sample code for uploading infotype 185.

REPORT zhrpyn_in_0185

NO STANDARD PAGE HEADING LINE-SIZE 255 MESSAGE-ID zhr.

INCLUDE zhrpyr_in_screen.

*INTERNAL TABLE FOR INSERTING DATA INTO THE BDC SESSION

DATA: BEGIN OF i_record OCCURS 0,

  • data element: PERNR_D

  • pernr(8),

pernr LIKE pa0185-pernr,

  • data element: SUBTY

subty(002),

  • data element: BEGDA

begda(010),

  • data element: ENDDA

endda(010),

  • data element: IDNUM

icnum(030),

  • data element: FLAG

flag(1),

begindate TYPE d,

END OF i_record.

*************************************************************************

  • changed on 24.02.2006 CR::PADK904014

*************************************************************************

*Internal table for getting the files from the directory

DATA: i_file_list TYPE epsfili OCCURS 0 WITH HEADER LINE.

  • Internal Table for getting required files names from the retrieved flat file list

DATA: BEGIN OF lt_final_list OCCURS 0,

date TYPE date, "sy-datum,

time LIKE sy-timlo,

name(80),

name1(80),

fullpath(85),

END OF lt_final_list.

  • Internal table to store Error messages

DATA: BEGIN OF it_error_msg OCCURS 0,

pernr(10) TYPE c,

msg(255) TYPE c,

END OF it_error_msg.

  • Internal table to store payroll area information

DATA :BEGIN OF it_pa0001 OCCURS 0,

pernr TYPE pa0001-pernr,

abkrs TYPE pa0001-abkrs,

bukrs TYPE pa0001-bukrs,

END OF it_pa0001.

  • Internal table to store hiring action data.

DATA: BEGIN OF it_pa0000 OCCURS 0,

pernr LIKE pa0000-pernr,

massn LIKE pa0000-massn,

stat2 LIKE pa0000-stat2,

END OF it_pa0000.

  • Internal table to Error data

DATA: BEGIN OF it_error_data OCCURS 0,

row(600),

END OF it_error_data.

*Internal table to store error files

DATA : BEGIN OF it_temp OCCURS 0,

name(85),

END OF it_temp.

*Internal table for storing the incorrect personnel number

DATA :BEGIN OF i_pernr OCCURS 0,

pernr(5000),

END OF i_pernr.

*Internal Table for Upload of records from flat file.

DATA : BEGIN OF i_copy OCCURS 0,

row(600) TYPE c,

END OF i_copy.

DATA : BEGIN OF i_table OCCURS 0,

row(600) TYPE c,

END OF i_table.

*Standard Table used for Batch Input Processing.

DATA : BEGIN OF bdcdata OCCURS 0.

INCLUDE STRUCTURE bdcdata.

DATA : END OF bdcdata.

  • Variables.

DATA : v_len TYPE i,

v_head(1) TYPE c,

v_date TYPE string,

v_nor(10) TYPE c,

v_space TYPE string,

v_thead(1) TYPE c,

v_tdate TYPE string,

v_tnor(10) TYPE c,

v_tspace TYPE string,

v_abkrs(2),

v_begda(8),

v_count(10) TYPE n,

v_pernr_1(8),

v_date_c TYPE d,

v_begindate TYPE sy-datum,

v_qid LIKE apqi-qid, " to store the QID

v_f_n TYPE string,

v_f_e TYPE string,

v_filename TYPE rlgrap-filename, " for download the error pernr

v_filename1 TYPE rlgrap-filename, " for download the error pernr

v_wa_zqid_filename LIKE zqid_filename,

v_panflag,

v_index TYPE i.

*Constants

DATA : c_session TYPE d0100-mapn VALUE 'ZHRPY_185',

c_tcode LIKE tstc-tcode VALUE 'PA30',

c_infotype(4) VALUE '0185'.

START-OF-SELECTION.

*Function for uploading the files from the application server

CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'

EXPORTING

dir_name = '\lgcsap_IN\IT0185'

TABLES

dir_list = i_file_list

EXCEPTIONS

invalid_eps_subdir = 1

sapgparam_failed = 2

build_directory_failed = 3

no_authorization = 4

read_directory_failed = 5

too_many_read_errors = 6

empty_directory_list = 7

OTHERS = 8.

  • Return Code check

IF sy-subrc <> 0.

MESSAGE e000 WITH 'Location Invalid'.

STOP.

ENDIF.

  • Get all the file names based on timstamp.

LOOP AT i_file_list.

*Copy file name into the final internal table

MOVE i_file_list-name TO lt_final_list-name.

  • Assuming files are txt

SEARCH i_file_list-name FOR '.txt'.

*Return Code Check

IF sy-subrc = 0.

  • Search for the file name

SEARCH i_file_list-name FOR 'LGCSAPINPIT0185'

STARTING AT 1

ENDING AT 15.

  • Return code Check

IF sy-subrc <> 0.

CONCATENATE '\lgcsap_IN\IT0185\' i_file_list-name INTO it_temp-name.

APPEND it_temp.

*Displaying the error message

  • MESSAGE e000 WITH 'File Not Found'.

*

ELSE.

*code to change date format from ddmmyy to yymmdd for sorting

v_date_c = i_file_list-name+15(8).

CONCATENATE v_date_c4(4) v_date_c2(2) v_date_c+0(2) INTO

lt_final_list-date.

  • Getting the time date value

lt_final_list-time = i_file_list-name+23(6).

  • Concatenate the text to get the input file name.

CONCATENATE '\lgcsap_IN\IT0185' lt_final_list-name INTO

lt_final_list-fullpath SEPARATED BY '\'.

  • Concatenate the text to get the output file name.

CONCATENATE '\lgcsapREAD_IN\IT0185_READ' lt_final_list-name

INTO lt_final_list-name1 SEPARATED BY '\'.

  • Append the list.

APPEND lt_final_list.

ENDIF.

ENDIF.

ENDLOOP.

IF lt_final_list[] IS INITIAL.

MESSAGE i000 WITH text-012.

LEAVE LIST-PROCESSING.

ELSE.

  • sort the table by Date and Time.

SORT lt_final_list BY date ASCENDING time ASCENDING.

  • Get all files selected

LOOP AT lt_final_list.

  • Initialize the table

CLEAR: i_copy,

i_record,

v_filename,

v_filename1,

v_f_n,

v_f_e.

REFRESH: i_copy,i_record.

SPLIT lt_final_list-name AT '.' INTO v_f_n

v_f_e.

CONCATENATE v_f_n '_ERR.txt' INTO v_filename.

v_filename1 = lt_final_list-name.

  • For uploading the flat file from application server.

OPEN DATASET lt_final_list-fullpath FOR INPUT IN TEXT MODE ENCODING DEFAULT.

  • Return code Check

IF sy-subrc <> 0.

*Display the error message that file cannot be opened.

MESSAGE e000 WITH 'File cannot be opened'.

STOP.

ELSE.

DO.

  • Read The records from the flat file into internal table

READ DATASET lt_final_list-fullpath INTO i_copy.

  • Return Code Check.

IF sy-subrc NE 0.

EXIT.

ELSE.

*Append the records

APPEND i_copy.

ENDIF.

ENDDO.

ENDIF.

  • Close the dataset after reading the records.

CLOSE DATASET lt_final_list-fullpath.

  • Moving the flat file into another folder

OPEN DATASET lt_final_list-name1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

  • Return Code Check.

IF sy-subrc = 0.

*looping at the internal table

LOOP AT i_copy.

  • Transfer the file.

TRANSFER i_copy TO lt_final_list-name1.

ENDLOOP.

ENDIF.

  • Close the dataset after writing the records.

CLOSE DATASET lt_final_list-name1.

*Return code check

IF sy-subrc = 0 .

  • To get the number of lines in the internal table

DESCRIBE TABLE i_copy LINES v_len.

  • To separate the data into Header, Actual data and Trailer records.

LOOP AT i_copy.

*To separate the header record.

IF sy-tabix = 1 AND i_copy-row+0(1) = 'H'.

  • Split the header data into respective fields.

SPLIT i_copy AT '|' INTO v_head

v_date

v_nor

v_space.

  • Display Header Records

WRITE: 'HEADER RECORDS'.

WRITE: / v_head,

v_date,

v_nor.

  • To separate the trailer records

ELSEIF sy-tabix = v_len AND i_copy-row+0(1) = 'T'.

  • Split the Trailer data into respective fields.

SPLIT i_copy AT '|' INTO v_thead

v_tdate

v_tnor

v_tspace.

  • Display Trailer Records

WRITE: / 'TRAILER RECORDS'.

WRITE: / v_thead,

v_tdate,

v_tnor.

  • To separate the actual records.

ELSE.

  • Split the Actual data into respective fields.

SPLIT i_copy AT '|' INTO i_record-pernr

i_record-begda

i_record-endda

i_record-subty

i_record-icnum.

  • Display Records

WRITE: / i_record-pernr,

i_record-begda,

i_record-endda,

i_record-subty,

i_record-icnum.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = i_record-pernr

IMPORTING

output = i_record-pernr.

CONCATENATE i_record-begda+6(4)

i_record-begda+3(2)

i_record-begda+0(2)

INTO i_record-begindate .

  • Append the records

APPEND i_record.

ENDIF.

ENDLOOP.

ENDIF.

*Check if the number of rows in header & trailer r same.

IF v_nor <> v_tnor .

*Display error message.

MESSAGE e000 WITH text-000.

ENDIF.

IF i_record[] IS NOT INITIAL.

*For all the records read from the application server file, get their payroll area from table PA0001.

SELECT pernr abkrs bukrs INTO TABLE it_pa0001

FROM pa0001

FOR ALL ENTRIES IN i_record

WHERE pernr = i_record-pernr

AND begda LE i_record-begindate

AND endda GE i_record-begindate .

IF sy-subrc = 0.

SORT it_pa0001 BY pernr.

ENDIF.

*For all the records read from the application server file, get their hiring information

SELECT pernr massn stat2 INTO TABLE it_pa0000

FROM pa0000

FOR ALL ENTRIES IN i_record

WHERE pernr = i_record-pernr

AND stat2 = '3'

AND massn = '01'.

IF sy-subrc = 0.

SORT it_pa0000 BY pernr.

ENDIF.

ENDIF.

IF i_record[] IS NOT INITIAL.

*Open a new session.

PERFORM open_group.

*loop at the internal table i_record

LOOP AT i_record.

v_index = sy-tabix.

READ TABLE it_pa0000 WITH KEY pernr = i_record-pernr BINARY SEARCH.

*Check if the employee is hired and is active.

IF sy-subrc NE 0.

*Get the personnel number into internal table i_pernr

it_error_msg-pernr = i_record-pernr.

it_error_msg-msg = 'Employee not hired or is in inactive status'.

CONCATENATE i_record-pernr

i_record-begda

i_record-endda

i_record-subty

i_record-icnum

INTO it_error_data-row

SEPARATED BY '|'.

*append the record

APPEND it_error_msg.

CLEAR it_error_msg.

APPEND it_error_data.

CLEAR it_error_data.

DELETE i_record WHERE pernr = i_record-pernr .

CONTINUE.

ENDIF.

READ TABLE it_pa0001 WITH KEY pernr = i_record-pernr BINARY SEARCH.

IF sy-subrc EQ 0.

*Check if the payroll area belongs to india

  • IF it_pa0001-abkrs NE 'TC' OR it_pa0001-bukrs NE 'TCSI'.

IF NOT ( it_pa0001-bukrs IN com_code ) .

*Get the personnel number into internal table i_pernr

it_error_msg-pernr = i_record-pernr.

it_error_msg-msg = 'Invalid Payroll Area.'.

CONCATENATE i_record-pernr

i_record-begda

i_record-endda

i_record-subty

i_record-icnum

INTO it_error_data-row

SEPARATED BY '|'.

*append the record

APPEND it_error_msg.

CLEAR it_error_msg.

APPEND it_error_data.

CLEAR it_error_data.

DELETE i_record WHERE pernr = i_record-pernr.

CONTINUE.

ENDIF.

ENDIF.

IF i_record-subty = '02'.

PERFORM pan_validation USING i_record-icnum CHANGING v_panflag.

IF v_panflag = 'Y'.

*Get the personnel number into internal table i_pernr

it_error_msg-pernr = i_record-pernr.

it_error_msg-msg = 'Invalid PAN NO.'.

CONCATENATE i_record-pernr

i_record-begda

i_record-endda

i_record-subty

i_record-icnum

INTO it_error_data-row

SEPARATED BY '|'.

*append the record

APPEND it_error_msg.

CLEAR it_error_msg.

APPEND it_error_data.

CLEAR it_error_data.

DELETE i_record INDEX v_index.

CONTINUE.

ENDIF.

ENDIF.

PERFORM bdc_dynpro USING 'SAPMP50A' '1000'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=INS'.

*INSERTING PERSONNEL NUMBER

PERFORM bdc_field USING 'RP50G-PERNR'

i_record-pernr.

PERFORM bdc_field USING 'BDC_CURSOR'

'RP50G-SUBTY'.

*INSERTING INFOTYPE

PERFORM bdc_field USING 'RP50G-CHOIC'

c_infotype.

*INSERTING SUBTYPE

PERFORM bdc_field USING 'RP50G-SUBTY'

i_record-subty.

*FOR SA

IF i_record-subty = '01'.

PERFORM bdc_dynpro USING 'MP018500' '2040'.

PERFORM bdc_field USING 'BDC_CURSOR'

'P0185-AUTH1'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=UPD'.

*INSERTING BEGIN DATE

PERFORM bdc_field USING 'P0185-BEGDA'

i_record-begda.

*INSERTING END DATE

PERFORM bdc_field USING 'P0185-ENDDA'

i_record-endda.

*INSERTING THE SA IDENTITY NO

PERFORM bdc_field USING 'P0185-ICNUM'

i_record-icnum.

*INSERTING THE SA ID

PERFORM bdc_field USING 'P0185-AUTH1'

'SATC'.

*FOR PF

ELSEIF i_record-subty = '02'.

PERFORM bdc_dynpro USING 'MP018500' '2240'.

PERFORM bdc_field USING 'BDC_CURSOR'

'P0185-ICNUM'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=UPD'.

*INSERTING BEGIN DATE

PERFORM bdc_field USING 'P0185-BEGDA'

i_record-begda.

*INSERTING END DATE

PERFORM bdc_field USING 'P0185-ENDDA'

i_record-endda.

*INSERTING THE PF IDENTITY NO

PERFORM bdc_field USING 'P0185-ICNUM'

i_record-icnum.

*FOR GRATUITY

ELSEIF i_record-subty = '03'.

PERFORM bdc_dynpro USING 'MP018500' '2340'.

PERFORM bdc_field USING 'BDC_CURSOR'

'P0185-AUTH1'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=UPD'.

*INSERTING BEGIN DATE

PERFORM bdc_field USING 'P0185-BEGDA'

i_record-begda.

*INSERTING END DATE

PERFORM bdc_field USING 'P0185-ENDDA'

i_record-endda.

*INSERTING THE GRATUITY IDENTITY NO

PERFORM bdc_field USING 'P0185-ICNUM'

i_record-icnum.

*INSERTING THE GRATUITY ID

PERFORM bdc_field USING 'P0185-AUTH1'

'GRTC'.

ENDIF.

  • Insert the data from bdcdata table to the session

PERFORM bdc_insert.

  • Initialize the internal table.

REFRESH bdcdata.

CLEAR : i_record.

CLEAR : v_index .

ENDLOOP.

PERFORM close_group.

PERFORM submit_session.

ENDIF.

IF v_qid IS INITIAL.

v_qid = '9999999999'.

ENDIF.

*display the message that the session is created

MOVE: v_qid TO v_wa_zqid_filename-qid,

lt_final_list-name TO v_wa_zqid_filename-filename,

lt_final_list-fullpath TO v_wa_zqid_filename-fullpath,

lt_final_list-name1 TO v_wa_zqid_filename-readpath,

  • 'TC' TO v_wa_zqid_filename-abkrs.

com_code TO v_wa_zqid_filename-bukrs.

INSERT INTO zqid_filename VALUES v_wa_zqid_filename.

  • Delete the dataset that has been read.

DELETE DATASET lt_final_list-fullpath.

CONCATENATE '\saplgc_IN\ERROR_LOG\' v_filename INTO v_filename.

CONCATENATE '\saplgc_IN\ERROR_LOG\' v_filename1 INTO v_filename1.

IF it_error_msg[] IS NOT INITIAL.

  • Moving the error log data into application server location

OPEN DATASET v_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

  • Return Code Check.

IF sy-subrc = 0.

  • Transfer the file.

LOOP AT it_error_msg.

TRANSFER it_error_msg TO v_filename.

ENDLOOP.

ENDIF.

  • Close the dataset after writing the records.

CLOSE DATASET v_filename.

  • Moving the error data into application server location

OPEN DATASET v_filename1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

  • Return Code Check.

IF sy-subrc = 0.

  • Transfer the file.

LOOP AT it_error_data.

TRANSFER it_error_data TO v_filename1.

ENDLOOP.

ENDIF.

  • Close the dataset after writing the records.

CLOSE DATASET v_filename1.

ENDIF.

REFRESH : it_error_data,

it_error_msg.

CLEAR: v_qid,

lt_final_list-name,

lt_final_list-fullpath,

lt_final_list-name1.

ENDLOOP.

ENDIF.

IF NOT it_temp[] IS INITIAL.

LOOP AT it_temp.

*delete the dataset that has been read.

DELETE DATASET it_temp-name.

MESSAGE e000 WITH text-013.

ENDLOOP .

ENDIF.

  • OPEN DATASET i_final_list-name1 FOR OUTPUT IN TEXT MODE ENCODING

*DEFAULT.

*

    • Return Code Check.

  • IF sy-subrc = 0.

*

**looping at the internal table

  • LOOP AT i_copy.

*

    • Transfer the file.

  • TRANSFER i_copy TO i_final_list-name1.

  • ENDLOOP.

  • ENDIF.

*

    • Close the dataset after writing the records.

  • CLOSE DATASET i_final_list-name1.

*

    • Delete the dataset that has been read.

  • DELETE DATASET i_final_list-fullpath.

*

  • ENDLOOP.

**Get the name of the file into a variable

  • concatenate 'C:\Error_Pernr\IT0041_185ERR' sy-datum sy-UZEIT '.txt'

*into

  • v_filename.

*

**Download the mismatching pernr into a separate flat file.

  • CALL FUNCTION 'GUI_DOWNLOAD'

  • EXPORTING

  • FILENAME = v_filename

  • TABLES

  • DATA_TAB = i_pernr

  • 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.

*

**Return code check

  • IF SY-SUBRC <> 0.

  • message e000 with text-005.

  • ENDIF.

*

**Get the number of rows in the internal table i_pernr

  • describe table i_pernr lines v_count.

*

**Check for the number of rows

  • if v_count > 0.

*

**Display message

  • message i000 with v_count text-006.

  • endif.

*

**Display message that session has been created successfully.

  • MESSAGE s000 WITH text-004 c_sesSION .

*----


  • Subroutine for opening a new session.

*----


*ENDLOOP.

**************************************************************************

  • Form open_group

**************************************************************************

  • text

**************************************************************************

FORM open_group.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

client = sy-mandt

group = c_session

keep = 'X'

user = sy-uname

IMPORTING

qid = v_qid

EXCEPTIONS

client_invalid = 1

destination_invalid = 2

group_invalid = 3

group_is_locked = 4

holddate_invalid = 5

internal_error = 6

queue_error = 7

running = 8

system_lock_error = 9

user_invalid = 10

OTHERS = 11.

  • Return Code Check.

IF sy-subrc NE 0.

WRITE: / 'UNSUCESSFUL'.

ENDIF.

ENDFORM. "open_group

*

**************************************************************************

  • 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

**************************************************************************

  • Form BDC_INSERT

**************************************************************************

  • Subroutine to insert the Internal Table BDCDATA into the session

**************************************************************************

FORM bdc_insert.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

tcode = c_tcode "PA30

TABLES

dynprotab = bdcdata

EXCEPTIONS

internal_error = 1

not_open = 2

queue_error = 3

tcode_invalid = 4

printing_invalid = 5

posting_invalid = 6

OTHERS = 7.

ENDFORM. "BDC_INSERT

**************************************************************************

  • Form CLOSE_GROUP

**************************************************************************

  • Subroutine for closing a session

**************************************************************************

FORM close_group .

CALL FUNCTION 'BDC_CLOSE_GROUP'

EXCEPTIONS

not_open = 1

queue_error = 2

OTHERS = 3.

  • Return Code Check.

IF sy-subrc NE 0.

WRITE: 'UNSUCCESSFUL'.

STOP.

ENDIF.

ENDFORM. " CLOSE_GROUP

************************************************************************

  • END OF PROGRAM

************************************************************************

&----


*& Form pan_validation

&----


  • text

----


  • -->P_I_RECORD_ICNUM text

----


FORM pan_validation USING p_i_record_icnum

CHANGING v_panflag.

DATA : v_panno TYPE string ,

v_panlen TYPE i,

v_pan_alpha(6),

v_pan_num(4).

DATA : c_alpha TYPE string VALUE 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',

c_numeric TYPE string VALUE '0123456789'.

CLEAR : v_panflag.

*Get the PAN No into a string variable

v_panno = i_record-icnum.

*Condense the string v_panno

CONDENSE v_panno.

*Get the PAN NO length into a variable

v_panlen = STRLEN( v_panno ).

*If the PAN No length is not 10

IF v_panlen NE 10.

*Set the PAN flag

v_panflag = 'Y'.

ELSE.

*Get the First five alphabets into v_pan_alpha

v_pan_alpha = v_panno+0(5).

*Get the last alphabet into v_pan_alpha

v_pan_alpha5(1) = v_panno9(1).

*Get the numbers into v_pan_num

v_pan_num = v_panno+5(4).

*IF v_pan_alpha contains literals other than alphabet

IF v_pan_alpha CN c_alpha.

*Set the PAN flag

v_panflag = 'Y'.

*IF v_pan_num contains non-numeric contants .

ELSEIF v_pan_num CN c_numeric.

*Set the PAN flag

v_panflag = 'Y'.

ENDIF.

ENDIF.

CLEAR : v_panno , v_panlen , v_pan_alpha , v_pan_num.

ENDFORM. " pan_validation

&----


*& Form submit_session

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM submit_session .

DATA: v_date(10).

CONCATENATE sy-datum6(2) '.' sy-datum4(2) '.' sy-datum+0(4)

INTO v_date.

SUBMIT zrsbdcsub USING SELECTION-SCREEN '1000'

WITH mappe EQ c_session

WITH von EQ sy-datum

  • WITH bis EQ v_date

WITH logall EQ 'X'

WITH z_verarb EQ 'X'

WITH fehler EQ ' '

AND RETURN.

ENDFORM. " submit_session

Reward points if helpful,

Regards,

Sumanjeet.