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

Report Program - Writing data to Application Server

Former Member
0 Likes
410

Hello,

I am having one Report program that is used to download some files to the Application Server. There is one folder in the application Server. For writing the files to the Application server Folder, Whether I need to get the Access or not?

I will explain the scenario clearly.

Suppose my systems are

D - Development & Testing are done here. (USer Id - DSYS

P - Production System. (USer Id - PSYS )

Diff User Ids for 2 servers.

In P server there is one folder where I need to write the file.

I need to test the program from D system . For that Do I need to get the writing access for my DSYS(User Id for D System ) or not ?

Or Can I write to that folder without any access?

Thanks in Advance.

Regards,

LIJO JOHN

2 REPLIES 2
Read only

Former Member
0 Likes
364

hi check this program in this i am uploading the data to the application server and to the pc.

REPORT ZHRO_CORPEDIA_VENDOR_REPORT

NO STANDARD PAGE HEADING

line-size 140

MESSAGE-ID zhris.

----


  • T A B L E S

----


TABLES: pa0105, "Infotype 0105 (Communications)

pa0002, " Infotype 0002 (Personal Data)

pa0000.

----


  • T Y P E D E C L A R A T I O N S

----


*---Types for the final table

types : begin of ty_final ,

pernr like pa0000-pernr, "Personnel number

nachn like pa0002-nachn, "Last Name

vorna like pa0002-vorna, "First Name

usrid like pa0105-usrid, "Communication ID/Number

usrid_long like pa0105-usrid_long,"Communication: Long Identification/Number

end of ty_final.

*---Types to get active employee

TYPES:BEGIN OF TY_PA0000,

PERNR LIKE PA0000-PERNR,

BEGDA LIKE PA0000-BEGDA,

ENDDA LIKE PA0000-ENDDA,

STAT2 LIKE PA0000-STAT2,

END OF TY_PA0000.

----


  • I N T E R N A L T A B L E S

----


*-----Internal table to hold the data of emp like userid, email

data: it_pa0105 like p0105 occurs 0 with header line ,

*-----Internal table to check for active employee

it_pa0000 TYPE STANDARD TABLE OF TY_pa0000 with header line,

*-----Internal table to hold the data of emp like first, last name

it_pa0002 like p0002 occurs 0 with header line,

*-----Internal table for final data

it_final type standard table of ty_final with header line.

*-----Internal table for Error Records

DATA: BEGIN OF T_ERROR OCCURS 0,

PERNR LIKE PERNR-PERNR,

MESSAGE(60) TYPE C,

END OF T_ERROR.

----


  • VARIABLE DECLARATIONS *

----


data : v_pernr like pa0000-pernr,

v_lines type i.

----


  • CONSTANTS DECLARATION

----


*-----Subty '0001' for the system username from pa0105

CONSTANTS: C_SUBTY LIKE PA0105-SUBTY VALUE '0001',

*-----Subty '0010' for the email from pa0105

C_SUBTY1 LIKE PA0105-SUBTY VALUE '0010'.

----


  • S E L E C T I O N - S C R E E N

----


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.

parameters:p_date like sy-datum obligatory.

select-options:s_pernr for pa0000-pernr no intervals.

parameters:p_stat2 like pa0000-stat2 .

SELECTION-SCREEN end OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK FILE WITH FRAME TITLE TEXT-FIL.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS: P_PC RADIOBUTTON GROUP RAD USER-COMMAND USR. "PC

SELECTION-SCREEN COMMENT 3(5) TEXT-SC1.

PARAMETERS: P_UNIX RADIOBUTTON GROUP RAD DEFAULT 'X'. "UNIX

SELECTION-SCREEN COMMENT 11(5) TEXT-SC2.

parameters:p_file like rlgrap-filename.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN begin OF LINE.

SELECTION-SCREEN COMMENT 1(16) TEXT-002.

parameters:p_file1 like rlgrap-filename.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK FILE.

----


  • INITIALIZATION *

----


initialization.

concatenate '/VOLSAP/HRIS/ARAMARK_' 'DEMO' '.ASC' INTO P_FILE.

concatenate '/VOLSAP/HRIS/ARAMARK_' 'DEMO' '.PRN' INTO P_FILE1.

p_stat2 = '3'.

----


  • AT SELECTION-SCREEN *

----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

    • F4 help for the flat file path

PERFORM F4_FILEPATH.

----


  • S T A R T - O F - S E L E C T I O N

----


START-OF-SELECTION.

PERFORM GET_DATA.

----


  • T O P - O F - P A G E

----


top-of-page.

PERFORM HEADER.

----


  • E N D - O F - S E L E C T I O N

----


END-OF-SELECTION.

PERFORM TRANSFER_DATA.

perform write_error_log..

&----


*& Form F4_FILEPATH

&----


  • F4 HELP FOR FILE PATH

----


FORM F4_FILEPATH.

IF P_UNIX = 'X'.

  • F4 help for UNIX

CALL FUNCTION 'F4_DXFILENAME_4_DYNP'

EXPORTING

DYNPFIELD_FILENAME = 'P_FILE'

DYNAME = SY-CPROG

DYNUMB = SY-DYNNR

FILETYPE = 'P'

LOCATION = 'A'

SERVER = ''.

IF SY-SUBRC <> 0.

MESSAGE E000 WITH TEXT-E01 P_FILE.

ENDIF.

ELSEIF P_PC = 'X'.

  • F4 help for PC

clear p_file.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

DEF_PATH = P_FILE

MASK = ',..'

MODE = '0 '

TITLE = 'Choose File'

IMPORTING

FILENAME = P_FILE

EXCEPTIONS

INV_WINSYS = 1

NO_BATCH = 2

SELECTION_CANCEL = 3

SELECTION_ERROR = 4

OTHERS = 5.

ENDIF.

ENDFORM. " F4_FILEPATH

&----


*& Form OUTPUT_CORPEDIA_VENDOR_FILE

&----


  • Output Demographic file

----


FORM OUTPUT_CORPEDIA_VENDOR_FILE .

IF P_PC = 'X'.

data: v_pcfile type string.

v_pcfile = p_file.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = v_pcfile

FILETYPE = 'ASC'

TABLES

DATA_TAB = it_final.

skip 2.

WRITE:/ 'RECORDS SUCCESSFULLY TRANSFERED TO FILE:' , P_FILE .

WRITE:/ 'NO OF RECORDS DOWNLOADED : ', V_LINES .

else.

data: outrec(200) type c .

loop at it_final.

OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE encoding DEFAULT.

outrec+0(8) = it_final-pernr.

outrec+8(40) = it_final-nachn.

outrec+48(40) = it_final-vorna.

outrec+88(30) = it_final-usrid.

outrec+118(40) = it_final-usrid_long.

transfer outrec to p_file.

CLOSE DATASET p_file.

OPEN DATASET P_FILE1 FOR OUTPUT IN TEXT MODE encoding DEFAULT.

transfer outrec to p_file1.

clear outrec.

CLOSE DATASET p_file1.

endloop.

skip 2.

WRITE:/ 'RECORDS SUCCESSFULLY TRANSFERED TO FILE :' , P_FILE .

WRITE:/ 'NO OF RECORDS DOWNLOADED : ', V_LINES .

skip 2.

WRITE:/ 'RECORDS SUCCESSFULLY TRANSFERED TO FILE :' , P_FILE1 .

WRITE:/ 'NO OF RECORDS DOWNLOADED : ', V_LINES .

skip 2.

ENDIF.

ENDFORM. " OUTPUT_CORPEDIA_VENDOR_FILE

&----


*& Form GET_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_DATA .

clear:it_pa0000,

it_pa0000[].

*---Get the active employee

select PERNR

BEGDA

ENDDA

STAT2

from pa0000

into table it_pa0000

where pernr in s_pernr

and endda >= p_date

and begda <= p_date

and stat2 = p_stat2.

if sy-subrc = 0.

sort it_pa0000 by pernr endda descending.

delete adjacent duplicates from it_pa0000 comparing pernr.

endif.

loop at it_pa0000.

clear : it_pa0002 ,it_pa0105,

it_pa0002[] , it_pa0105[] ,

v_pernr.

v_pernr = it_pa0000-pernr.

*---Get first name, last name of the active employee

CALL FUNCTION 'HR_READ_INFOTYPE'

EXPORTING

PERNR = V_pernr

INFTY = '0002'

BEGDA = p_date

ENDDA = p_date

TABLES

INFTY_TAB = it_pa0002.

*---Get SAP ID , email of the active employee

CALL FUNCTION 'HR_READ_INFOTYPE'

EXPORTING

PERNR = v_pernr

INFTY = '0105'

BEGDA = p_date

ENDDA = p_date

TABLES

INFTY_TAB = it_pa0105.

sort it_pa0002 by pernr begda descending.

delete adjacent duplicates from it_pa0002 comparing pernr.

sort it_pa0105 by pernr subty begda descending.

delete adjacent duplicates from it_pa0105 comparing pernr subty.

*---Get employee pernr, First name ,Last name into final table

if not it_pa0002[] is initial.

read table it_pa0002 index 1.

if sy-subrc = 0.

it_final-pernr = it_pa0002-pernr.

it_final-nachn = it_pa0002-nachn.

it_final-vorna = it_pa0002-vorna.

else.

*----message for the name if not maintained.

T_ERROR-PERNR = it_pa0002-PERNR.

CONCATENATE TEXT-EMI '0002'

INTO T_ERROR-MESSAGE SEPARATED BY SPACE.

APPEND T_ERROR.

CLEAR T_ERROR.

ENDIF.

else.

*---- message for infotype if not maintained.

skip 2.

write:/ 'Infotype 0002 is not maintained for this pernr', it_pa0000-pernr.

skip 2.

endif.

if not it_pa0105[] is initial.

read table it_pa0105 with key pernr = it_pa0002-pernr

subty = C_SUBTY.

*--Get SYSTEM USERNAME the final table

if sy-subrc = 0.

it_final-usrid = it_pa0105-usrid.

else.

*--message for the SAP ID if not maintained.

T_ERROR-PERNR = it_pa0105-PERNR.

CONCATENATE TEXT-003 '0105'

INTO T_ERROR-MESSAGE SEPARATED BY SPACE.

APPEND T_ERROR.

CLEAR T_ERROR.

endif.

*--Get Email into the final table

read table it_pa0105 with key pernr = it_pa0002-pernr

subty = C_SUBTY1.

if sy-subrc = 0.

it_final-usrid_long = it_pa0105-usrid_long.

else.

*--message for the Email ID if not maintained.

T_ERROR-PERNR = it_pa0105-PERNR.

CONCATENATE TEXT-004 '0105'

INTO T_ERROR-MESSAGE SEPARATED BY SPACE.

APPEND T_ERROR. CLEAR T_ERROR.

endif.

else.

*--message for infotype 0105 if not maintained.

skip 2.

write:/ 'Infotype 0105 is not maintained for this pernr', it_pa0000-pernr.

skip 2.

ENDIF.

if not it_final-pernr is initial.

append it_final.

clear it_final.

endif.

endloop.

ENDFORM. " GET_DATA

&----


*& Form HEADER

&----


  • HEADER OF THE OUTPUT

----


FORM HEADER .

*----variables for the header

DATA: COL1(3) TYPE P. " column left side

DATA: COL2(3) TYPE P. " column right side

DATA: LGTH(3) TYPE P. " length of string

DATA: COMPANY_NAME(60) VALUE 'OfficeMax Inc.'. " Default

DATA: SUB_HEADER(60) VALUE ' '. " Default

WRITE: AT 1 'Report: ', SY-REPID. " left margin column

COL1 = ( SY-LINSZ - STRLEN( COMPANY_NAME ) ) / 2. " center company name

WRITE AT COL1 COMPANY_NAME. " default 'OfficeMax'

COL2 = SY-LINSZ - 16. " 16 columns from

WRITE: AT COL2 'Date:', SY-DATUM. " right margin.

WRITE: AT /1 'System: ', SY-SYSID(3) NO-GAP, '(' NO-GAP, SY-MANDT

NO-GAP, ')'.

LGTH = STRLEN( SY-TITLE ). " title length

COL1 = ( SY-LINSZ - LGTH ) / 2. " center it

WRITE AT COL1(LGTH) SY-TITLE. " the titlebar title

WRITE: AT COL2 'Time:', sy-uzeit. " time

WRITE: AT /1 'User: ', SY-UNAME. " username

COL1 = ( SY-LINSZ - STRLEN( SUB_HEADER ) ) / 2. " center company name

WRITE AT COL1 SUB_HEADER. " description fld

WRITE: AT COL2 'Page:', SY-PAGNO LEFT-JUSTIFIED. " page number

ENDFORM. " HEADER

&----


*& Form TRANSFER_DATA

&----


  • TRANSFER DATA TO PC/APPLICATION SERVER

----


FORM TRANSFER_DATA .

describe table it_final lines v_lines .

*---get data into Application Server.

PERFORM OUTPUT_CORPEDIA_VENDOR_FILE .

ENDFORM. " TRANSFER_DATA

&----


*& Form write_error_log

&----


  • getting messages for unexisted data

----


FORM write_error_log .

LOOP AT T_ERROR.

skip 2.

write:/1 'Personnel no' , 20 'Message' .

WRITE: /1 T_ERROR-PERNR, 20 T_ERROR-MESSAGE.

ENDLOOP.

ENDFORM. " write_error_log

reward points if useful,

venkat.

Read only

0 Likes
364

Dear Venkat,

I am having the program, that is working Fine. My doubt is regarding the Application Server Folder Access.

Whether I need to get the Access from BASIS Guys or not?

Please have a look into my question and help me.

Anyway thanks for your quick reply.

Regards,

LIJO.