Error while give out put to file

Namasiva

Member
Hi,
I have created a program that should out put a flat file in a folder.
but while running the code i am getting the following error :


Report is now running. Press Ctrl-C to cancel

** Unable to open file: /extdata/desktop/dtlive/Board/Sales_details.txt.
Press space bar to continue.

How could i resolve this issue?

Pls find below the codes.


/* added for desktop version */
{mfdtitle.i "2+ "}
/* end desktop add */

define variable st-dt as DATE LABEL "Start date".
define variable end-dt as date LABEL "End date".

DEFINE VARIABLE outfile AS CHARACTER NO-UNDO.
def stream x.
def stream y.

def temp-table t1_hist no-undo

field t1_ship like ih_ship
field t1_name like ad_name
field t1_cust like ih_cust
field t1_name1 like ad_name
field t1_date as dat
field t1_part like idh_part
field t1_desc1 like pt_desc1
field t1_desc2 like pt_desc2
field t1_pl like pt_prod_line
field t1_qty as decimal format "->>>>>>9.99"
field t1_um like pt_um
field t1_price like idh_price
field t1_amt as decimal format "->>>>>>9.99"
field t1_cost as decimal format "->>>>>>9.99"
field t1_margin as decimal format "->>>>>>9.99"
index t1_part is primary unique t1_cust
t1_part
t1_date.
assign outfile = "" .

FORM
st-dt colon 19
end-dt colon 19

WITH FRAME a SIDE-LABELS WIDTH 80 ATTR-SPACE.
/* added for desktop version */
setframelabels(FRAME a:HANDLE).
{wbrp01.i}
repeat :
IF c-application-mode <> 'web' THEN
UPDATE st-dt end-dt WITH FRAME a.

{gpselout.i &printType = "printer"
&printWidth = 352
&pagedFlag = " "
&stream = " "
&appendToFile = " "
&streamedOutdisplayToTerminal = " "
&withBatchOption = "yes"
&displayStatementType = 1
&withCancelMessage = "yes"
&pageBottomMargin = 4
&withEmail = "yes"
&withWinprint = "yes"
&defineVariables = "yes"}
{mfrpchk.i}

/* end desktop add */
outfile = "/extdata/desktop/dtlive/Board/Sales_details.txt".
output stream x to value( outfile).
for each t1_hist :
delete t1_hist.
end.
for each ih_hist where
ih_inv_date >= st-dt and ih_inv_date <= end-dt no-lock,
each idh_hist where idh_inv_nbr = ih_inv_nbr
and idh_nbr = ih_nbr
and idh_site = ih_site
and idh_qty_inv <> 0 no-lock,
first cm_mstr where
cm_addr = ih_bill and cm_addr = ih_ship no-lock,
first ad_mstr where
ad_addr = ih_cust no-lock,
first pt_mstr where pt_part = idh_part no-lock,
first ar_mstr where ar_nbr = ih_inv_nbr no-lock:

find first t1_hist where t1_part = idh_part
and t1_cust = ih_cust
and t1_pl = pt_prod_line
and t1_date = ih_inv_date no-error.
if not available t1_hist then do:
create t1_hist.
assign
t1_date = ih_inv_date
t1_ship = ih_ship
t1_name = ad_name
t1_cust = ih_cust
t1_name1 = ad_name
t1_part = idh_part
t1_um = pt_um
t1_desc1 = pt_desc1
t1_desc2 = pt_desc2
t1_pl = pt_prod_line
t1_qty = idh_qty_inv
t1_amt = idh_qty_inv * idh_price
t1_cost = idh_qty_inv * idh_std_cost
t1_margin = t1_amt - t1_cost.
end.


end.


for each t1_hist by t1_date
by t1_cust
by t1_part
by t1_pl :
put stream x unformatted
string(t1_cust ) AT 1
string(t1_name1 ) AT 11
string(t1_ship ) AT 42
string(t1_name ) AT 51
string(t1_part ) AT 80
string(t1_um ) AT 102
string(t1_desc1) AT 105
string(t1_desc2 ) AT 130
string(t1_pl ) AT 156
string(year(t1_date),"9999") + " " + string(month(t1_date),"99") + " " + string(day(t1_date),"99") AT 162
string (t1_qty) AT 175
string (t1_amt) AT 182
string (t1_margin) AT 195
skip.



end. /* end of t1_hist */
{mfrtrail.i}
end.
output stream x close.
Message "The Sales Details sent to Board" VIEW-AS ALERT-BOX.

{wbrp04.i &frame-spec = a}
/* end of desktop . */


Its most urgent so kindly give me solution.
 

sphipp

Member
Some suggestions:
Have you got permissions to write to /extdata/desktop/dtlive/Board?
Do the Directories /extdata/desktop/dtlive, /extdata/desktop and /extdata exist?

 

sphipp

Member
Some suggestions:
Have you got permissions to write to /extdata/desktop/dtlive/Board?
Do the Directories /extdata/desktop/dtlive/Board, /extdata/desktop/dtlive, /extdata/desktop and /extdata exist?
You have a capital B in Board. Unix is case sensitive, so you probably need to check that /extdata/desktop/dtlive/Board is not actually /extdata/desktop/dtlive/board.
 

Namasiva

Member
Thanks for your reply

in Unix also we Defined as Board so there could not be any problem with File name.

all the user have permission to read write and modify .

I am able to write the files in Character version.

If i run the program in Desktop 2 version i am getting the error.


Thank you very much in advance..
 
Log in as the user used for telnet session in Desktop & verify if you have write access.

Second is dont give absolute path, just the file name. You can have the output in home folder.
 

sanjus

Member
Login as the user (the userid used in the connection manager for the desktop) in ChUI and check if this userid can create the file & has read/write permissions.

Also, should not use View-as alert-box for .NetUi/Desktop.

Hope this helps.
 

Namasiva

Member
Hi All,

Thanks for all your Help

the issue is resolved now. its related to file permission.

When ever the program create a file, the permission of the file is

-rw-rw-r
if the other user run the program it will not allow to modify the file and gives the error.

i have created the .txt file and change the permission to
-rwxrwxrwx

Now there is no problem, the codes are working fine.

Thanks once again for all your support.
 
Top