Open data set and close data set
hi all,
i have some doubt in open/read/close data set
how to transfer data from internal table to sequential file, how we find sequential file.
thanks and regards
chaitanya
Hi Chaitanya,
Refer Sample Code:
constants: c_split TYPE c
VALUE cl_abap_char_utilities=>horizontal_tab,
c_path TYPE char100
VALUE '/local/data/interface/A28/DM/OUT'.
Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : rb_pc RADIOBUTTON GROUP r1 DEFAULT 'X'
USER-COMMAND ucomm, "For Presentation
p_f1 LIKE rlgrap-filename
MODIF ID rb1, "Input File
rb_srv RADIOBUTTON GROUP r1, "For Application
p_f2 LIKE rlgrap-filename
MODIF ID rb2, "Input File
p_direct TYPE char128 MODIF ID abc DEFAULT c_path.
"File directory
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_f1.
*-- Browse Presentation Server
PERFORM f1000_browse_presentation_file.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_f2.
*-- Browse Application Server
PERFORM f1001_browse_appl_file.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF rb_pc = 'X' AND screen-group1 = 'RB2'.
screen-input = '0'.
MODIFY SCREEN.
ELSEIF rb_srv = 'X' AND screen-group1 = 'RB1'.
screen-input = '0'.
MODIFY SCREEN.
ENDIF.
IF screen-group1 = 'ABC'.
screen-input = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
*& Form f1000_browse_presentation_file
Pick up the filepath for the file in the presentation server
FORM f1000_browse_presentation_file .
CONSTANTS: lcl_path TYPE char20 VALUE 'C:'.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_path = lcl_path
mask = c_mask "',.,..'
mode = c_mode
title = text-006
IMPORTING
filename = p_f1
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
flg_pre = c_x.
ENDIF.
ENDFORM. " f1000_browse_presentation_file
*& Form f1001_browse_appl_file
Pick up the file path for the file in the application server
FORM f1001_browse_appl_file .
DATA: lcl_directory TYPE char128.
lcl_directory = p_direct.
CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
EXPORTING
directory = lcl_directory
filemask = c_mask
IMPORTING
serverfile = p_f2
EXCEPTIONS
canceled_by_user = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE e000(zmm) WITH text-039.
flg_app = 'X'.
ENDIF.
ENDFORM. " f1001_browse_appl_file
*& Form f1003_pre_file
Upload the file from the presentation server
FORM f1003_pre_file .
DATA: lcl_filename TYPE string.
lcl_filename = p_f1.
IF p_f1 IS NOT INITIAL.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lcl_filename
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = i_input
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE s000 WITH text-031.
EXIT.
ENDIF.
ELSE.
PERFORM populate_error_log USING space
text-023.
ENDIF.
ENDFORM. " f1003_pre_file
*& Form f1004_app_file
upload the file from the application server
FORM f1004_app_file .
REFRESH: i_input.
OPEN DATASET p_f2 IN TEXT MODE ENCODING DEFAULT FOR INPUT.
IF sy-subrc EQ 0.
DO.
READ DATASET p_f2 INTO wa_input_rec.
IF sy-subrc EQ 0.
*-- Split The CSV record into Work Area
PERFORM f0025_record_split.
*-- Populate internal table.
APPEND wa_input TO i_input.
CLEAR wa_input.
IF sy-subrc <> 0.
MESSAGE s000 WITH text-030.
EXIT.
ENDIF.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
ENDFORM. " f1004_app_file
Move the assembly layer file into the work area
FORM f0025_record_split .
CLEAR wa_input.
SPLIT wa_input_rec AT c_split INTO
wa_input-legacykey
wa_input-bu_partner
wa_input-anlage.
ENDFORM. " f0025_record_split
Reward points if this helps.
Manish
Similar Messages
-
Exception Handling for OPEN DATA SET and CLOSE DATA SET
Hi ppl,
Can you please let me know what are the exceptions that can be handled for open, read, transfer and close data set ?
Many Thanks.HI,
try this way....
DO.
TRY.
READ DATASET filename INTO datatab.
CATCH cx_sy_conversion_codepage cx_sy_codepage_converter_init
cx_sy_file_authority cx_sy_file_io cx_sy_file_open .
ENDTRY.
READ DATASET filename INTO datatab.
End of changes CHRK941728
IF sy-subrc NE 0.
EXIT.
ELSE.
APPEND datatab.
ENDIF.
ENDDO. -
Download using open data set and close data set
can any body please send some sample pgm using open data set and close data set .the data should get downloaded in application server
very simple pgm neededHi Arun,
See the Sample code for BDC using OPEN DATASET.
report ZSDBDCP_PRICING no standard page heading
line-size 255.
include zbdcrecx1.
*--Internal Table To hold condition records data from flat file.
Data: begin of it_pricing occurs 0,
key(4),
f1(4),
f2(4),
f3(2),
f4(18),
f5(16),
end of it_pricing.
*--Internal Table To hold condition records header .
data : begin of it_header occurs 0,
key(4),
f1(4),
f2(4),
f3(2),
end of it_header.
*--Internal Table To hold condition records details .
data : begin of it_details occurs 0,
key(4),
f4(18),
f5(16),
end of it_details.
data : v_sno(2),
v_rows type i,
v_fname(40).
start-of-selection.
refresh : it_pricing,it_header,it_details.
clear : it_pricing,it_header,it_details.
CALL FUNCTION 'UPLOAD'
EXPORTING
FILENAME = 'C:\WINDOWS\Desktop\pricing.txt'
FILETYPE = 'DAT'
TABLES
DATA_TAB = it_pricing
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7.
WRITE : / 'Condition Records ', P_FNAME, ' on ', SY-DATUM.
OPEN DATASET P_FNAME FOR INPUT IN TEXT MODE.
if sy-subrc ne 0.
write : / 'File could not be uploaded.. Check file name.'.
stop.
endif.
CLEAR : it_pricing[], it_pricing.
DO.
READ DATASET P_FNAME INTO V_STR.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
write v_str.
translate v_str using '#/'.
SPLIT V_STR AT ',' INTO it_pricing-key
it_pricing-F1 it_pricing-F2 it_pricing-F3
it_pricing-F4 it_pricing-F5 .
APPEND it_pricing.
CLEAR it_pricing.
ENDDO.
IF it_pricing[] IS INITIAL.
WRITE : / 'No data found to upload'.
STOP.
ENDIF.
loop at it_pricing.
At new key.
read table it_pricing index sy-tabix.
move-corresponding it_pricing to it_header.
append it_header.
clear it_header.
endat.
move-corresponding it_pricing to it_details.
append it_details.
clear it_details.
endloop.
perform open_group.
v_rows = sy-srows - 8.
loop at it_header.
perform bdc_dynpro using 'SAPMV13A' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RV13A-KSCHL'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RV13A-KSCHL'
it_header-f1.
perform bdc_dynpro using 'SAPMV13A' '1004'.
perform bdc_field using 'BDC_CURSOR'
'KONP-KBETR(01)'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'KOMG-VKORG'
it_header-f2.
perform bdc_field using 'KOMG-VTWEG'
it_header-f3.
**Table Control
v_sno = 0.
loop at it_details where key eq it_header-key.
v_sno = v_sno + 1.
clear v_fname.
CONCATENATE 'KOMG-MATNR(' V_SNO ')' INTO V_FNAME.
perform bdc_field using v_fname
it_details-f4.
clear v_fname.
CONCATENATE 'KONP-KBETR(' V_SNO ')' INTO V_FNAME.
perform bdc_field using v_fname
it_details-f5.
if v_sno eq v_rows.
v_sno = 0.
perform bdc_dynpro using 'SAPMV13A' '1004'.
perform bdc_field using 'BDC_OKCODE'
'=P+'.
perform bdc_dynpro using 'SAPMV13A' '1004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
endif.
endloop.
*--Save
perform bdc_dynpro using 'SAPMV13A' '1004'.
perform bdc_field using 'BDC_OKCODE'
'=SICH'.
perform bdc_transaction using 'VK11'.
endloop.
perform close_group.
Hope this resolves your query.
Reward all the helpful answers.
Regards -
What is open data set and close data set
what is open data set and close data set,
how to use the files in sap directories ?hi,
Open Dataset is used to read or write on to application server ... other than that i am not sure that there exists any way to do the same ... here is a short description for that
FILE HANDLING IN SAP
Introduction
Files on application server are sequential files.
Files on presentation server / workstation are local files.
A sequential file is also called a dataset.
Handling of Sequential file
Three steps are involved in sequential file handling
OPEN
PROCESS
CLOSE
Here processing of file can be READING a file or WRITING on to a file.
OPEN FILE
Before data can be processed, a file needs to be opened.
After processing file is closed.
Syntax:
OPEN DATASET <file name> FOR {OUTPUT/INPUT/APPENDING}
IN {TEXT/BINARY} MODE
This statement returns SY_SUBRC as 0 for successful opening of file or 8, if unsuccessful.
OUTPUT: Opens the file for writing. If the dataset already exists, this will place the cursor at the start of the dataset, the old contents get deleted at the end of the program or when the CLOSE DATASET is encountered.
INPUT: Opens a file for READ and places the cursor at the beginning of the file.
FOR APPENDING: Opens the file for writing and places the cursor at the end of file. If the file does not exist, it is generated.
BINARY MODE: The READ or TRANSFER will be character wise. Each time n characters are READ or transferred. The next READ or TRANSFER will start from the next character position and not on the next line.
IN TEXT MODE: The READ or TRANSFER will start at the beginning of a new line each time. If for READ, the destination is shorter than the source, it gets truncated. If destination is longer, then it is padded with spaces.
Defaults: If nothing is mentioned, then defaults are FOR INPUT and in BINARY MODE.
PROCESS FILE:
Processing a file involves READing the file or Writing on to file TRANSFER.
TRANSFER Statement
Syntax:
TRANSFER <field> TO <file name>.
<Field> can also be a field string / work area / DDIC structure.
Each transfer statement writes a statement to the dataset. In binary mode, it writes the length of the field to the dataset. In text mode, it writes one line to the dataset.
If the file is not already open, TRANSFER tries to OPEN file FOR OUTPUT (IN BINARY MODE) or using the last OPEN DATASET statement for this file.
IF FILE HANDLING, TRANSFER IS THE ONLY STATEMENT WHICH DOES NOT RETURN SY-SUBRC
READ Statement
Syntax:
READ DATASET <file name> INTO <field>.
<Field> can also be a field string / work area / DDIC structure.
Each READ will get one record from the dataset. In binary mode it reads the length of the field and in text mode it reads each line.
CLOSE FILE:
The program will close all sequential files, which are open at the end of the program. However, it is a good programming practice to explicitly close all the datasets that were opened.
Syntax:
CLOSE DATASET <file name>.
SY-SUBRC will be set to 0 or 8 depending on whether the CLOSE is successful or not.
DELETE FILE:
A dataset can be deleted.
Syntax:
DELETE DATASET <file name>.
SY-SUBRC will be set to 0 or 8 depending on whether the DELETE is successful or not.
Pseudo logic for processing the sequential files:
For reading:
Open dataset for input in a particular mode.
Start DO loop.
Read dataset into a field.
If READ is not successful.
Exit the loop.
Endif.
Do relevant processing for that record.
End the do loop.
Close the dataset.
For writing:
Open dataset for output / Appending in a particular mode.
Populate the field that is to be transferred.
TRANSFER the filed to a dataset.
Close the dataset.
Regards
Anver
if hlped pls mark points -
IPhoto won't open. Modified and created dates say 12/31/69
iPhoto won't open. Modified and created dates say 12/31/69. Help! OS is Tiger. Older G4 Powerbook.
As a test launch iPhoto with the Option key held down and try to create a new, test library. Can you? If you can then your current library is damaged and needs to be repaired.
Apply the two fixes below in order as needed:
Fix #1
Launch iPhoto with the Command+Option keys held down and rebuild the library.
Select the options identified in the screenshot.
Fix #2
Using iPhoto Library Manager to Rebuild Your iPhoto Library
Download IPhoto Library Manager 4 for OS XC 10.6.8 and iPhoto 8.1.2 and later or iPhoto Library Manager 3 (for OS X 10.5.8 and iPhoto 7.1.5 and earlier) and launch.
Click on the Add Library button, navigate to your Home/Pictures folder and select your iPhoto Library folder.
Now that the library is listed in the left hand pane of iPLM, click on your library and go to the File ➙ Rebuild Library menu (iPLM 3) or Library ➙ Rebuild Library menu (iPLM 4) option.
In the next window name the new library and select the location you want it to be placed.
Click on the Create button.
Note: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments but not books, calendars or slideshows. The original library will be left untouched for further attempts at fixing the problem or in case the rebuilt library is not satisfactory.
OT -
GL Account Start date and Close date
Hi,
Is it possible to maintain start date and close date of a GL account
Thanks & Regards
RadhaRequirement is, from a specific date the GL account should allow for posting and in the same way the GL account should not allow for posting for a specific posting.
So is it possible to give validity period for a GL account -
Can TestStand open, read, write and close binary files?
From a TestStand sequence, I need to open, read, write and close binary files. Does TestStand support this capability?
Christine -
In the past I have used the C/C++ Adapter to call directly into the CVI RTE functions. The CVI functions I have used are OpenFile, WriteFile and CloseFile. The functions are exported from the DLL as CVI_OpenFile, CVI_WriteFile, and CVI_CloseFile. I just had to make sure that on termination of the sequence, that the integer handle was properly released by calling the close function.
If you are using LabVIEW, you could call directly into the low level VIs to do a similar set of operations.
Scott Richardson (NI)
Scott Richardson
National Instruments -
What is the difference between "create set" and "create dynamic set"?
What is the difference between "create set" and "create dynamic set"?
we have a complete cube ready for production that was tested and working without any issues in non-r2. we found that some "create set" assignments don't work in R2. But when changed to from "create set" to "create dynamic set"?
they are working, However, not sure how it will impact other areas of the cube.Thanks YuliaKlimov, I can reproduce this issue, but I cannot explain the different behaviors between SSAS 2008 and 2008R2. As a workaround,
could you try to use dynamic set or create statics set but with fixed member for example:
CREATE
SET CURRENTCUBE.[Prior Month] AS
[Date].[Date Key].&[20050723].PrevMember
, DISPLAY_FOLDER = 'Relative Period Sets';
Personally, I think your set is dynamic set, because the currentmember is changed base on current selection. You can also submit this issue
on below official link to get confirmation from Product Group:
https://connect.microsoft.com/SQLServer/
Thanks,
Raymond
Raymond Li - MSFT -
i have problem with my wifi in 4 S, i cant connect to any wifi itried resetting network setting and reset all setting but the result was the same, its only keeps searching for wifi and cant find any, itried to use OTHER but also didnt work.please help me???
If Join was on then your home wi-fi must be set to Non-Broadcast. If you did not set this up (maybe your provider did) then you will need to find the Network Name they used, and any password they used. The SSID is Security Set ID and to see more try http://en.wikipedia.org/wiki/SSID . Basically it is the name used to identify your router/network. A lot of times the installer will leave it set as LinkSys, or Broadcom or whatever the manufacturer set it as for default. Your best bet is to get whoever installed it to walk you through how they set it up, giving you id's and passwords so you can get in. HOWEVER, if you are not comfortable with this (if you set security wrong, etc.) you would be well ahead of the game to hire a local computer tech (networking) to get this working for you. You can also contact the vendor of your router and get help (if it is still in warranty), or at least get copies of the manuals as pdf files. Sorry I can't give you more help, I hope this gives you an idea where to go from here to find more.
-
How to open an URL and close the URL window, using adobe javascript
Hi,
Is it possible to open an URL and close the URL back again(without allowing the user to perform any other operation)? I was able to acheive the opening of the URL, using the app.launchURL("address". true); - But here it lauches in new window, and how do i close the window using the javascript. Is it possible?
Thanks.Hi all
In addition to what Bobby W - Adobe TS added, you might find
the following useful as a bypass or workaround to the pesky prompt.
var pw=window.parent;pw.opener=window.self;window.open("
http://www.adobe.com");
pw.close();
I think this will only work for IE browsers. Actually, I
think the whole window.close() only works for IE, but could be
wrong about that.
Cheers... Rick -
Is there a keyboard shortcut in OS 10.6 for "open folder window" and "close folder window"? I have a hand condition at the moment that makes it painful to mouse the cursor over to the arrow and click it (for instance, in the sidebars for Finder or iTunes) to open or close a folder. If anyone knows a keyboard shortcut for this, I'd really appreciate it--thanks!
OS X keyboard shortcuts
-
Issue with the functions "add matching sets" and "modify matching sets"
Hi,
Though 'None' access permission is set for the functions 'Add Matching Sets' and 'Modify Matching Sets', they are accessible.
Is this a bug with the tool? or am I missing something?
Thanks in advance,
Madansorry, missed the version details.
I'm using MDM 5.5 SP6. -
What is data archiving and DMS(Data Management System) in SAP
what is data archiving and DMS(Data Management System) in SAP
Welcome to SCN. Before posting questions please search for available information here and in the web. Please also read the Rules of Engagement before further posting.
Edited by: kishan P on Aug 31, 2010 1:06 PMHi,
Filtering at the IDoc Level
Identify the filter object (BD59)
Modify the distribution model
Segment Filtering
specify the segments to be filtered (BD56)
The Reduced IDoc Type
Analyze the data.
Reduce the IDoc type (BD53)
Thanks and regards. -
How to make a Infocube as data source and upload data? urgent
Hi all,
I have 2 same InfoCubes, and I want to make the test InfoCube(ZCO_1T) as data source and upload data to another Cube(ZCO_1), Now I has Generated Export DataSource on ZCO_1T and create a update rule between ZCO_1T and ZCO_1. what will I do the next step? Thanks.hi delve,
once u generate datasource from test cube it acts as an data source for further upload.
now u choose update target3.x in additional functions in context menu of the test cube.
u will get an infopackage pop up with data target to the cube ZCO_1,processing to datatarget only.
selection criterion can bve selected from the first tab.
under schedule tab you can start extraction.
reward points if helpful. -
Select Records between Begin Date/Time and End Date/Time
Hi, I need to select records from table GLPCA where the CPUDT and CPUTM are between a START DATE/TIME and END DATE/TIME.
I have the below logic from an SAP Solution, but it doesn't seem to be working right in my opinion. It is picking up records earlier than the date ranges. Can anyone tell me how I might be able to accomplish this? I'm hoping this is an easy one for the ABAPPERs...
Thanks,
START DATE 20091022
START TIME 125736
END DATE 20091022
END TIME 135044
CPUDT 20091022
CPUTM 100257
SELECT * FROM GLPCA
WHERE ( CPUDT >= STARTDATE AND ( CPUTM >= STARTTIME OR ( CPUDT <= ENDDATE AND CPUTM <= ENDTIME ) ) ).Thank you all! I ended up using the following:
SELECT * FROM GLPCA
WHERE RYEAR IN L_R_RYEAR
AND ( ( CPUDT = STARTDATE AND CPUTM >= STARTTIME ) OR CPUDT > STARTDATE )
AND ( ( CPUDT = ENDDATE AND CPUTM <= ENDTIME ) OR CPUDT < ENDDATE ).
This child was born from the following thread that was found:
update date and time of client record
Maybe you are looking for
-
ITunes gives error message when I try to open it
iTunes recently stopped working on my iMac... Any help is greatly appreciated. Here is a copy of the error: Process: iTunes [2610] Path: /Applications/iTunes.app/Contents/MacOS/iTunes Identifier: com.apple.iTunes Version:
-
Trying to create a service that starts at boot
People, I'm trying to create a service that will start at boot (in single-user mode, actually). I am up and running but I do NOT want to run the service now. I only want to run the service when the machine reboots. I've been rummaging around all day
-
How do I submit to procedure with a variable number of controls in portlet?
I need to submit to a stored procedure but my portlet has a variable number of controls. How do I do this? In the past I have always had an input parameter for each control. In this case the number of controls vary at runtime. Is there a way to submi
-
Problems installing Oracle 9i R2 on RH3SA
Hi, i´m trying to install oracle in linux, all configs before the instalation look good (the script to verificate the setup of environment variables and memory config don´t show any problem). After configure the linux, i run the installer (./runInsta
-
HT1338 I try to update twice at the end it show me could not save file or corrupt
I try to update twice at the end it show me could not save file or corrupt