‎2007 Jul 31 2:01 PM
Hi all,
I am using a dataset to tempororily store some data in my program. the thing is if my program is executed by multiple users at a same time, the same dataset './mytempfile' is used and everything goes wrong. so suggest me how to overcome this.
OPEN DATASET './mytempfile' FOR OUTPUT IN BINARY MODE.
IF sy-subrc EQ 0.
LOOP AT t_myfile.
TRANSFER t_myfile TO './mytempfile'.
ENDLOOP.
CLOSE DATASET './mytempfile'.
ENDIF.
OPEN DATASET './mytempfile' FOR INPUT IN BINARY MODE.
IF sy-subrc EQ 0.
DO.
CLEAR t_mybin.
READ DATASET './mytempfile' INTO t_mybin MAXIMUM LENGTH 255.
IF sy-subrc NE 0.
EXIT.
ELSE.
APPEND t_mybin.
ENDIF.
ENDDO.
CLOSE DATASET './mytempfile'.
ENDIF.
DELETE DATASET './mytempfile'.
IF sy-subrc NE 0.
MESSAGE 'Error when deleting MY file'(008) TYPE 'I'.
LEAVE LIST-PROCESSING.
ENDIF.
‎2007 Jul 31 3:23 PM
Well I don;t know why you are using a dataset to temp store data but if you must. You can use something to make each file name unique, maybe add the username to the end of the file and if that is not enough then perhaps a timestamp or long timestamp.
‎2007 Jul 31 3:41 PM
Well, you can create dynamic file names.
The file names can be a concatenation of filename + date + time + username + random number.
please reward points for the useful answers
Regards
Vivek
‎2007 Jul 31 5:37 PM
I would store the data in a internal table while you are processing. Then once processing has been completed you can move the contents of the internal table to a external file, the filename can be a parameter on the selection screen, or you can use the dynamic names mentioned earlier.
With this method each time a user executes the transaction/program ABAP will generate a separate working area on the disk for the internal table. Even if you have 10 people running at the same time they will be witting to 10 different internal tables. All that is left is to manage the name of the external file.