Open dataset - Lines getting truncated-Question cancelled
Question cancelled
Message was edited by:
Arjun Puthuruthy
Walter - I ultimately removed the line feed statement Removed the other additions too.
open dataset dset for output in legacy text mode message msg_tab.
'#' is gone. Waiting to hear back from the legacy system team.
Aparna - You are right.. We have been noticing the same issue for other programs as well. But users are used to checking in notepad (very difficult convincing them).. Was there any problem @ the Unix end in your project? I am yet to check with the legacy system team if it's fine at their end..
Hope all goes well
Else I will re-visit this thread.
Thanks to all.
Regards,
DS
Edited by: D S on Jun 12, 2008 4:02 PM
Similar Messages
-
Truncated record in OPEN DATASET ENCODING NON-UNICODE
Hi,
I have to read a Unicode created file into a non-unicode SAP System, version 4.7.
When I make the OPEN DATASET using ENCODING UTF-8 y get a CONVT_CODEPAGE dump. That´s odd cause my system is non-unicode. I don´t wanna use IGNORING CONVERSION ERRORS attribute, the output will be corrupt.
But when I use ENCODING NON-UNICODE or ENCODING DEFAULT the READ DATASET mysteriously truncate the record which try to read from real 401 characters to 361 characters. Variable is string.
I can see full records through AL11.
Any ideas?
Thanks,
Pablo.Hi,
Try using:
open dataset filename in text mode encoding default for input
ignoring conversion errors.
As said in AL11 its coming so the above code is used for that.
Hope this will surely help you !!!
Regards,
Punit -
Hi,
I'm transferring data through an ABAP program to a file in background. The data is transferred ok, but the whole data gets inserted in the file as a single line.
I'm using the commands: OPEN DATASET file FOR OUTPUT IN TEXT MODE and all its variants ENCODING, LINEFEED, etc and also try ending my row data with CL_ABAP_CHAR_UTILITIES constants for end of lines (it is takes as Text and gets concatenated in the row).
Is there any way in which the data in the file writes in the new lines instead of one line?
Thanks & regardsHey Sebastien,
While transferring data, You should do it in a loop and endloop. And then close the dataset. Also I always recommend you to take a Field in the ITAB with some Flag or some Name like Tabnam so that you can always play with the data as you want.
Example : if you are transferring QMEL table data make sure your structure will be like mentioned below.
TYPES : BEGIN OF ty_qmel,
qmnum TYPE qmel-qmnum, "NOTIFICATION NUMBER
qmart TYPE qmel-qmart, "NOTIFICATION TYPE
tabname TYPE char10, "TABLE NAME FOR IDENTIFICATION-----> This makes you to identify which table data it is.
END OF ty_qmel,
Then While reading the data transfered from one system A(Data transferred from) to another system B(reading the Transfered data). It will be easy if you do like this.
OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING DEFAULT MESSAGE gv_mes IGNORING CONVERSION ERRORS.
DO.
READ DATASET file INTO gv_string.
If sy-subrc = 0.
IF gv_string CS 'QMEL'. -
> Note you can always Identity which table data it is
CALL METHOD cl_abap_container_utilities=>read_container_c
EXPORTING
im_container = gv_string
IMPORTING
ex_value = wa_qmel
EXCEPTIONS
illegal_parameter_type = 1
OTHERS = 2.
APPEND wa_qmel TO it_qmel.
Endif.
Else.
Exit
Endif.
ENDDO.
CLOSE DATASET file.
Hope this helps,
Regards,
Bhargav. -
We are beginning to prepare for the Unicode enabling of our custom ABAP programs and I have a question about the new OPEN DATASET statement. We have programs that write sequential files for use by the following:
1) ABAP programs that execute on our own SAP system
2) Non-SAP programs that execute in our data center
3) Programs (which may or may not be SAP) that execute in the data centers of other completely independent companies.
Conversely, we have programs that read files supplied by those systems.
After reading through a lot of information, I am reaching the conclusion that for our files that contain only character data, it would be safe for us to modify our OPEN DATASET statements simply to use u201COPEN DATASET IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORSu201D without attempting to be more explicit with some of the other options that are available.
Can any of you confirm that this is (or is not) a valid assumption?yes you can go ahead with that..for the text files and chardata files
OPEN DATASET IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORSu201D -
# Question
I have tried to download 5.0.1 on MAC X 10.6.8. Clicking download, I get a question from MAC --save or name application to open. Saving to desktop doesn't work. It appears in download, but not in desktop. What now?On Mac OS, plugins are installed to a common location, usually ''' /Library/Internet Plugins''' for system-wide availability or to '''~/Library/Internet Plugins''' for a specific user. Ref: http://kb.mozillazine.org/Issues_related_to_plugins#Background
Does Java 1.6.0_31 work on Safari or another browser?
I also found the following, in case it helps:
*http://reviews.cnet.com/8301-13727_7-57414869-263/how-to-use-java-applets-in-os-x-after-java-2012-003-update/
*http://stackoverflow.com/questions/6411909/how-to-downgrade-jre-jdk-on-mac-osx -
I have PowerBook G4, running 10.5.8. Went to upgrade and says OS too old. I went back to older version of foxfire. Now I have a circle with a line through it and when I try to open it I get,You cannot open the application “Firefox” because it is not supported on this architecture. Thanks for the help.
Firefox 3.6.x is the last available from Mozilla for PPC Macs. <br />
http://www.mozilla.com/en-US/firefox/all-older.html
For older Macs that aren't supported in Firefox 4+ versions, try TenFourFox for PowerPC's running Mac 10.4.11 & 10.5.8 . <br />
http://www.floodgap.com/software/tenfourfox/<br />
http://tenfourfox.blogspot.com/ <br />
https://code.google.com/p/tenfourfox/wiki/PluginsNoLongerSupported -
Getting 'Invalid argument' error while uisng OPEN DATASET. Help!
Hi Experts,
I am trying to read a file from a shared server location using OPEN DATASET as shown below.
OPEN DATASET file_name FOR INPUT IN TEXT MODE ENCODING UTF-8 MESSAGE msg.
The file_name i gave is '
CNSGN-PRE-DM.COM\FUNCTIONAL\INVENTORY.CSV'.
The program compiles perfectly. But when I run the program I am getting 'Invalid argument' error. I have checked the authorization to the server, file name, file availability and everything is fine.
Strangely this code was working fine a week ago.
What could be the problem? Kindly help me!
Thanks
GopalHi Chndrasekhar,
You mean to say the we cannot use OPEN DATASET for reading file in shared server location. For example a shared folder in my PC.
Is there something wrong in the file name path I have given? It started with '//'. Do I have to start the file path wih 'file://..'?
Thanks
Gopal -
I have just purchased a new apple cordless keyboard. The numeric line of keys along the top are not functioning as they should. For example I am unable to get a question mark or a forward slash. I have tried holding down both shift and alt keys.
Thanks for prompt response - I tried what you suggested but I'm afraid it has not helped. It seems as though the line of number keys along the top aren't actually doing what is printed on them. Some are OK, but the further towards the right hand side of the keyboard you go, the less predicatable it becomes. So whilst the second key from the left gives me 1 and ! when holding the shift key, by the time I get to the 6 when I press and hold shift I get ^ rather than & symbol which is what is actually printed on the key. The & symbol is actually on the next key along - and when I hit the key with 8 I get * rather than the ( which is printed on they key but actually located on the next key along. Things get even more muddled by the time I am over on the right hand side as rather than a question mark (I have had to type the word as I cannot find the symbol anywhere!) I get this _ and the other symbol marked on the key is a comma, but I get - instead. It is going to drive me mad if every time I want to type something it is a guessing game....! What do you suggest - question mark
-
When I try to open word,excel or powerpoint I get a question mark what should I do
when I try to open word,excel or powerpoint I get a question mark what should I do
Look in Applications/Utilities/Console to see if there are any error messages. If so, post them here
Bob -
Your security questions do not match what I put in when I opened the account, why can't I get security questions that have my answers?
From a Kappy post
The Three Best Alternatives for Security Questions and Rescue Mail
1. Use Apple's Express Lane.
Go to https://expresslane.apple.com ; click 'See all products and services' at the
bottom of the page. In the next page click 'More Products and Services, then
'Apple ID'. In the next page select 'Other Apple ID Topics' then 'Forgotten Apple
ID security questions' and click 'Continue'. Please be patient waiting for the return
phone call. It will come in time depending on how heavily the servers are being hit.
2. Call Apple Support in your country: Customer Service: Contact Apple support.
3. Rescue email address and how to reset Apple ID security questions.
A substitute for using the security questions is to use 2-step verification:
Two-step verification FAQ Get answers to frequently asked questions about two-step verification for Apple ID. -
When I open Firefox I get a blank box in the middle of the screen with a grey bar and a (?) and the page is frozen as if the computer is frozen ~~~ I have to load two (2) Firefox pages in order to get Firefox to work? Any suggestion as to how to fix this problem?
CS2 is very old and reached its "end of life" a while back. So probably won't run on modern operating systems. If you can still run it, you'll need to uninstall what you have and re-install with the download link below to activate it.
Error: Activation Server Unavailable | CS2, Acrobat 7, Audition 3
Nancy O. -
Question re ENCODING cp option of OPEN DATASET statement
I'm working on a 6.0 system with 4.6 data that I've downloaded from the 4.6 system and uploaded to the 6.0 system.
The 4.6 data has "umlauts" in it (like when "o's" have two dots above them in Scandinavian names), and when my READ DATASET executes on the 6.0 server, my try block is catching a CX_SY_CONVERSION_CODEPAGE error.
I'm assuming that to solve this, I will need to specify the codepage of the 4.6 server in the ENCODING codepage option of the OPEN DATASET statement that's exceuting on the 6.0 server.
Will this solve the problem? If not, what do I try next ?
Also, how can I determine the system codpage of my current ABAP "text environment"? I know all the possibilities are in table TCP0P, but how do I know which one is "active" ???
Thanks guys.Hi,
Refer this OPEN DATASET in ECC6.0 solves your problem and also check the abap documentation for system codepage and text environment.
For unicode systems,system code page is UTF-16.
Thanks.
Ramya. -
Hi Friends,
I am facing a problem with OPEN DATASET to transfer data from XSTRING field to the text file.
Then problem is like this I have a internal table type XSTRING. Which will havehi suresh,
check this,
data:
begin of STRUC2,
F1 type c,
F2(20) type c,
end of STRUC2.
Put data into text format
move-corresponding STRUC to STRUC2.
Write data to file
open dataset DSN in text mode for output encoding utf-8.
transfer STRUC2 to DSN.
close dataset DSN.
Read data from file
clear STRUC.
open dataset DSN in text mode for input encoding utf-8.
read dataset DSN into STRUC2.
close dataset DSN.
move-corresponding STRUC2 to STRUC.
write: / STRUC-F1, STRUC-F2.
The textual storage in UTF-8 format ensures that the created files are platform-independent.
Case 2: Old non-Unicode format must be retained
Write data to file
open dataset DSN in legacy text mode for output.
transfer STRUC to DSN.
close dataset DSN.
read from file
clear STRUC.
open dataset DSN in legacy text mode for input.
read dataset DSN into STRUC.
close dataset DSN.
write: / STRUC-F1, STRUC-F2. -
Problem in Open dataset in background
Hi All,
Iam facing the problem in Open dataset in background. It is working fine in foreground.
Iam able to read only one line from the application server file in background.
Please find below the code.
IF sy-batch = wl_x.
OPEN DATASET pa_sfile FOR INPUT IN TEXT MODE encoding default. "
IF sy-subrc = 0.
DO.
READ DATASET pa_sfile INTO wf_string.
IF sy-subrc <> 0.
EXIT.
ELSE.
SPLIT wf_string AT cl_abap_char_utilities=>horizontal_tab INTO wa_upload-
field1 wa_upload-field2 wa_upload-field3
wa_upload-field4 wa_upload-field5 wa_upload-field6 wa_upload-field7
wa_upload-field8 wa_upload-field9 wa_upload-field10 wa_upload-field11 wa_upload-field12 wa_upload-field13 wa_upload-field14 wa_upload-field15 wa_upload-field16 wa_upload-field17 wa_upload-field18 wa_upload-field19 wa_upload-field20 wa_upload-field21 wa_upload-field22 wa_upload-field23
wa_upload-field24 wa_upload-field25 wa_upload-field26 wa_upload-field27 wa_upload-field28 wa_upload-field29 wa_upload-field30 wa_upload-field31 wa_upload-field32 wa_upload-field33 wa_upload-field34 wa_upload-field35 wa_upload-field36 .
APPEND wa_upload TO int_upload.
CLEAR wa_upload.
ENDIF.
ENDDO.
CLOSE DATASET pa_sfile.
Thanks in advance.
Quick suggestions are highly appreciated.
Best Regards,
Brahma ReddyThanks for the reply.
Here is the whole code.
Here iam submitting one job to the backgrond. But if iam executing it in debugging mode by changing the values of sy-batch( without submitting to background ) at run time, my program is working fine.
REPORT zvtraffic_carrier_upload
NO STANDARD PAGE HEADING LINE-SIZE 255
MESSAGE-ID zmmx.
*Data Declarations *
TABLES: vtrkh,
vekp,
zvship_non_pkgs.
declaration of data
DATA:
wf_filename LIKE ibipparms-path, "file with path
wf_file LIKE ibipparms-path, "file
wf_extsn(3) TYPE c , "file extension
wf_recnt TYPE i,
wf_recok TYPE i,
*+001 Begin
wf_string TYPE string,
wf_mess TYPE string,
wf_field1 TYPE string,
wf_field2(30) TYPE c,
wf_sum_source_file TYPE rlgrap-filename ,
wf_sum_dest_file TYPE rlgrap-filename ,
wf_path LIKE rlgrap-filename,
wf_path TYPE salfile-longname
VALUE '/usr/sap/nfs/erp/UTL/',
*+001 End
wf_complete_file LIKE pcfile-path. "total file path
declaration of counters
DATA:
wc_rec(6) TYPE c, "total record counter
wc_success_rec(6) TYPE c, "no of rec.having no errors
wc_error_rec(6) TYPE c, "no of rec. having errors
wc_rec_tot(6) TYPE c. "total records
Constants declarations
CONSTANTS:
wl_x(1) TYPE c VALUE 'X', "X
wl_1 TYPE i VALUE '1', "Integer value
wl_e(1) TYPE c VALUE 'E', "Char value
wl_mode TYPE c VALUE 'N',
wl_update TYPE c VALUE 'S',
wl_trackno(13) TYPE c VALUE 'Tracking No. ',
wl_tcode(14) TYPE c VALUE 'ZVTRAFFICINPUT',
*+001 Begin:
wl_id(11) TYPE c VALUE 'CARRIERFILE',
wl_adm(100) TYPE c VALUE '[email protected]',
wl_u(1) TYPE c VALUE 'U', " Email through Internet
wl_int(3) TYPE c VALUE 'INT', " Communication method
wl_urgent(6) TYPE c VALUE 'Urgent',
wl_raw(3) TYPE c VALUE 'RAW',
wl_descr(48) TYPE c VALUE 'SAP Alert: Carrier upload',
wl_file(128) TYPE c VALUE '/usr/sap/nfs/erp/UTL/carrier.xls',
wl_jobname LIKE tbtcjob-jobname VALUE 'ZVTRAFFIC_UP',
wl_variant LIKE raldb-variant VALUE 'VMM01_ZVTRFFIC',
wl_action TYPE zaction VALUE 'MOV', "For moving file to other dir
wl_i TYPE c VALUE 'I',
wl_cmd(50) TYPE c VALUE '/usr/sap/nfs/erp/UTL/',
wl_57 TYPE i VALUE 57,
wl_m1(2) TYPE c VALUE 'M1', "value M1
wl_m2(2) TYPE c VALUE 'M2', "value M1
*+001 End:
wl_xls(3) TYPE c VALUE 'xls', "Char value
wl_value(1) TYPE c VALUE ','. "Char value
*Internal Tables Declarations *
internal table for holding data from excel file
*+001 begin
TYPES : BEGIN OF ty_dir,
dir(132) TYPE c,
END OF ty_dir.
*internal table to get the files in the direactory
DATA : int_dir TYPE ty_dir OCCURS 0 WITH HEADER LINE .
*work area for int_dir
DATA : wa_int_dir LIKE LINE OF int_dir.
DATA: ifiles TYPE TABLE OF salfldir WITH HEADER LINE.
*+001 end
TYPES: BEGIN OF int_upload,
field1(30) TYPE c, "
field2(30) TYPE c, "
field3(30) TYPE c, "
field4(30) TYPE c, "
field5(30) TYPE c, "
field6(30) TYPE c, "
field7(30) TYPE c, "
field8(30) TYPE c, "
field9(30) TYPE c, "
field10(30) TYPE c, "
field11(30) TYPE c, "
field12(30) TYPE c, "
field13(30) TYPE c, "
field14(30) TYPE c, "
field15(30) TYPE c, "
field16(30) TYPE c, "
field17(30) TYPE c, "
field18(30) TYPE c, "
field19(30) TYPE c, "
field20(30) TYPE c, "
field21(30) TYPE c, "
field22(30) TYPE c, "
field23(30) TYPE c, "
field24(30) TYPE c, "
field25(30) TYPE c, "
field26(30) TYPE c, "
field27(30) TYPE c, "
field28(30) TYPE c, "
field29(30) TYPE c, "
field30(30) TYPE c, "
field31(30) TYPE c, "
field32(30) TYPE c, "
field33(30) TYPE c, "
field34(30) TYPE c, "
field35(30) TYPE c, "
field36(30) TYPE c, "
END OF int_upload.
DATA: int_upload TYPE STANDARD TABLE OF int_upload.
declaring bdc table
DATA: int_bdcdata LIKE STANDARD TABLE OF bdcdata
INITIAL SIZE 0 WITH HEADER LINE.
DATA: wa_bdcdata LIKE bdcdata.
DATA:int_messages TYPE
STANDARD TABLE OF bdcmsgcoll INITIAL SIZE 0.
TYPES: BEGIN OF ty_error_data,
errtext(500) TYPE c,
END OF ty_error_data.
DATA: wa_messages LIKE LINE OF
int_messages.
DATA: wa_error_data TYPE
ty_error_data .
DATA: int_error_data TYPE
STANDARD TABLE OF ty_error_data INITIAL SIZE 0.
*Work Area declarations
Work area
DATA:
wa_upload LIKE LINE OF int_upload. "work area for int_upload
Selection Screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : pa_foreg RADIOBUTTON GROUP g1 USER-COMMAND rad DEFAULT 'X', " user command rad,
pa_backg RADIOBUTTON GROUP g1 .
SELECTION-SCREEN: SKIP.
Input File Location Specification
SELECTION-SCREEN BEGIN OF BLOCK b11 WITH FRAME TITLE text-002.
PARAMETERS pa_file LIKE rlgrap-filename
MODIF ID m1. "OBLIGATORY. "Input File -001
SELECTION-SCREEN END OF BLOCK b11.
*+001 Begin
SELECTION-SCREEN BEGIN OF BLOCK b12 WITH FRAME TITLE text-006.
PARAMETERS pa_sfile LIKE rlgrap-filename DEFAULT '/usr/sap/nfs/erp/UTL/carrier2'
LOWER CASE MODIF ID m2. " server filename
*PARAMETERS pa_batch AS CHECKBOX DEFAULT ' ' MODIF ID m2. "Background job
*+001 End
SELECTION-SCREEN END OF BLOCK b12.
SELECTION-SCREEN END OF BLOCK b1.
Event: INITIALIZATION
INITIALIZATION.
clear variables
refresh internal tables
REFRESH:int_upload.
clear Work areas
CLEAR: wa_upload.
A T S E L E C T I O N - S C R E E N
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_file. "-001
subroutine to display the batch data input file location
PERFORM f_get_filename.
*+001 Begin:
AT SELECTION-SCREEN OUTPUT.
IF pa_backg = wl_x.
LOOP AT SCREEN.
IF screen-group1 = wl_m2.
screen-invisible = space.
screen-active = '1'.
MODIFY SCREEN.
ELSE.
IF screen-group1 = wl_m1.
screen-input = '0'.
MODIFY SCREEN.
ENDIF.
ENDIF.
ENDLOOP.
ELSE.
LOOP AT SCREEN.
IF screen-group1 = wl_m2.
screen-input = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_sfile.
subroutine to display list of files in application server
PERFORM f_get_server_file.
*+001 End:
At Selection-Screen Event: validations check *
AT SELECTION-SCREEN .
validates the Selection Screen input
PERFORM f_check_input.
Event TOP-OF-PAGE
TOP-OF-PAGE.
Event: START-OF-SELECTION
START-OF-SELECTION.
*+001 Begin :
get the path for all files from the directory
PERFORM f_get_path.
set up background job
PERFORM f_background_job.
*+001 End:
*-001
CHECK pa_backg EQ ' '.
*-001
LOOP AT ifiles.
clear itab. refresh itab.
CONCATENATE wf_path ifiles-name INTO pa_sfile.
upload PC file to internal table int_UPLOAD
PERFORM f_upload_excel_file.
reformat data
PERFORM f_format_data.
upload formatted data into SAP system
break breddy.
PERFORM f_upload_data.
Event: END-OF-SELECTION
*END-OF-SELECTION.
display summary report
PERFORM f_display_report.
*+001 Begin
IF sy-batch = wl_x.
CONCATENATE '/usr/sap/trans/carrier2' '_'
sy-datum '_' sy-uzeit
INTO wf_sum_dest_file.
wf_sum_source_file = '/usr/sap/nfs/erp/UTL/carrier2'.
wf_sum_dest_file = '/usr/sap/trans/carrier2'.
ELSE.
wf_sum_source_file = pa_file.
wf_sum_dest_file = '/usr/sap/trans/carrier2'.
To move the processed file to Completed directory
PERFORM f_move_file_to_other_dir USING
wf_sum_source_file
wf_sum_dest_file.
ENDIF.
*+001 End
wait up to 60 seconds.
*& Form f_get_filename
Display the File Location
Called by: Main Program (AT SELECTION-SCREEN on VALUE-REQUEST)
Calls:
FORM f_get_filename.
CLEAR wf_filename.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = wf_fieldname
IMPORTING
file_name = wf_filename.
If the user press cancel button without selecting file name
then the file name will be initial and raise the error message
IF wf_filename IS INITIAL.
MESSAGE i000 WITH 'No File selected'(012).
LEAVE LIST-PROCESSING.
ENDIF.
pa_file = wf_filename.
ENDFORM. " f_get_filename
Form: F_CHECK_INPUT **
Description:
This subroutine is used to validate the Selection Screen inputs.
Called By: ZMISOPPLAN01 *
Calls: None *
FORM f_check_input.
if pa_foreg eq wl_X.
if sy-batch ne wl_X. " IF pa_foreg EQ wl_x. " +001
check file type
IF pa_file NS '.xls'.
MESSAGE e106.
ENDIF.
ENDIF. "+001
endif.
*+001 Begin:
wf_file = pa_sfile.
EXPORT wf_file TO MEMORY ID wl_id.
ENDIF. " Commented by Br
*+001 Begin
IF pa_backg EQ wl_x.
pa_sfile = '/usr/sap/nfs/erp/UTL/carrier2'.
OPEN DATASET pa_sfile FOR INPUT IN TEXT MODE ENCODING DEFAULT MESSAGE wf_mess.
IF sy-subrc NE 0.
MESSAGE e000(zmmx) WITH 'File not present in path /usr/sap/nfs/erp/UTL'.
LEAVE LIST-PROCESSING.
STOP.
ELSE.
CLOSE DATASET pa_sfile.
ENDIF.
ELSE.
OPEN DATASET pa_sfile FOR INPUT IN TEXT MODE ENCODING DEFAULT MESSAGE wf_mess.
IF sy-subrc NE 0.
MESSAGE e000(zmmx) WITH 'File not found:' pa_sfile.
LEAVE LIST-PROCESSING.
STOP.
ELSE.
CLOSE DATASET pa_sfile.
ENDIF.
ENDIF.
*+001 End:
ENDFORM. "f_check_input
*& Form f_upload_excel_file
Uploads an excel file from the workstation. The file is loaded *
into the internal table specified by int_out_tab. *
--> PA_FILE The name and path of the excel file to upload *
<-- int_UPLOAD Internal table that that will contain the data *
loaded from the excel file. *
FORM f_upload_excel_file.
*-001
TYPES truxs_t_text_data(4096) TYPE c OCCURS 0.
DATA: int_tab_input_data TYPE truxs_t_text_data.
*+001
IF sy-batch IS INITIAL.
*+001
uploading data into internal table int_upload from excel file
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_tab_raw_data = int_tab_input_data[]
i_filename = pa_file "-001
TABLES
i_tab_converted_data = int_upload
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
problems occur in file uploading
IF int_upload[] IS INITIAL.
MESSAGE i000 WITH 'No data uploaded from input file'(005).
LEAVE LIST-PROCESSING.
ENDIF.
*+001
ENDIF.
*+001
IF sy-batch = wl_x.
OPEN DATASET pa_sfile FOR INPUT IN TEXT MODE encoding default. " ENCODING DEFAULT MESSAGE wf_mess.
IF sy-subrc = 0.
DO.
READ DATASET pa_sfile INTO wf_string.
IF sy-subrc <> 0.
EXIT.
ELSE.
SPLIT wf_string AT cl_abap_char_utilities=>horizontal_tab INTO wa_upload-field1 wa_upload-field2 wa_upload-field3
wa_upload-field4 wa_upload-field5 wa_upload-field6 wa_upload-field7 wa_upload-field8
wa_upload-field9 wa_upload-field10 wa_upload-field11 wa_upload-field12 wa_upload-field13
wa_upload-field14 wa_upload-field15 wa_upload-field16 wa_upload-field17 wa_upload-field18
wa_upload-field19 wa_upload-field20 wa_upload-field21 wa_upload-field22 wa_upload-field23
wa_upload-field24 wa_upload-field25 wa_upload-field26 wa_upload-field27 wa_upload-field28
wa_upload-field29 wa_upload-field30 wa_upload-field31 wa_upload-field32 wa_upload-field33
wa_upload-field34 wa_upload-field35 wa_upload-field36 .
APPEND wa_upload TO int_upload.
CLEAR wa_upload.
ENDIF.
ENDDO.
CLOSE DATASET pa_sfile.
ELSE.
MESSAGE i000(zmmx) WITH 'File not found'.
LEAVE LIST-PROCESSING.
STOP.
ENDIF.
ENDIF.
+001
ENDFORM. "f_upload_excel_file
*& Form f_format_data
format the data to be uploaded
Called by: ZMISOPPLAN01
Calls: N/A
FORM f_format_data.
delete the header lines
DELETE int_upload WHERE
field1 CS 'SCAC' OR field1 CS 'Scac' OR field1 CS 'Carrier'.
delete lines with no carrier info
DELETE int_upload WHERE
field1 IS INITIAL OR field2 IS INITIAL.
SORT int_upload BY field2.
ENDFORM. " f_format_data
*& Form f_upload_data
Description:upload the data
FORM f_upload_data.
DATA: loc_priceperlb LIKE zvship_trk_data-act_per_lb,
loc_charprice(10) TYPE n,
loc_size TYPE i,
loc_pickupdate(10) TYPE c,
loc_totalwt LIKE zvship_trk_data-pkg_wgt.
CHECK NOT int_upload[] IS INITIAL.
DESCRIBE TABLE int_upload LINES wf_recnt.
LOOP AT int_upload INTO wa_upload.
SELECT COUNT(*) FROM zvship_trk_data WHERE trackn = wa_upload-field2.
IF sy-subrc = 0.
tracking no. exists in carrier database
CONCATENATE wl_trackno wa_upload-field2
' already exists in carrier tracking database' INTO
wa_error_data-errtext. "Error text of int_error_data
APPEND wa_error_data TO int_error_data.
ELSE.
SELECT SINGLE * FROM vtrkh WHERE trackn = wa_upload-field2.
IF sy-subrc <> 0.
tracking no. not in tracking database
CONCATENATE wl_trackno wa_upload-field2
' not found in tracking database' INTO
wa_error_data-errtext. "Error text of int_error_data
APPEND wa_error_data TO int_error_data.
ELSE.
must have freight charge
IF wa_upload-field20 IS INITIAL.
CONCATENATE wl_trackno wa_upload-field2
' has no total net charges' INTO
wa_error_data-errtext. "Error text of int_error_data
APPEND wa_error_data TO int_error_data.
CONTINUE.
ENDIF.
must have final delv. date
IF wa_upload-field25 IS INITIAL.
CONCATENATE wl_trackno wa_upload-field2
' has no final delivery date' INTO
wa_error_data-errtext. "Error text of int_error_data
APPEND wa_error_data TO int_error_data.
CONTINUE.
ENDIF.
all checks ok, build BDC for ZVTRAFFICINPUT
get total weight and compute price/lb
IF vtrkh-uevbtyp EQ wl_x.
SELECT SINGLE brgew INTO loc_totalwt
FROM zvship_non_pkgs
WHERE venum = vtrkh-vbeln.
ELSE.
SELECT SINGLE brgew INTO loc_totalwt
FROM vekp WHERE venum = vtrkh-vbeln.
ENDIF.
IF sy-subrc NE 0.
CONCATENATE wl_trackno wa_upload-field2
' has no total weight' INTO
wa_error_data-errtext. "Error text of int_error_data
APPEND wa_error_data TO int_error_data.
CONTINUE.
ENDIF.
price/lb = total net charges / total wt
loc_priceperlb = wa_upload-field20 / loc_totalwt.
WRITE loc_priceperlb TO loc_charprice LEFT-JUSTIFIED.
if no pickup date from VTRKH, use date from file
IF vtrkh-routeldat IS INITIAL.
loc_pickupdate = wa_upload-field23.
ELSE.
CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'
EXPORTING
input = vtrkh-routeldat
IMPORTING
output = loc_pickupdate.
ENDIF.
PERFORM f_set_bdc_val
USING :
'1' 'SAPLZVSHIP_TRAK' '0001',
' ' 'BDC_CURSOR' 'VIM_POSITION_INFO',
' ' 'BDC_OKCODE' '=AEND'.
PERFORM f_set_bdc_val
USING :
'1' 'SAPLZVSHIP_TRAK' '0001',
' ' 'BDC_CURSOR' 'ZVSHIP_TRK_DATA-EOD_DATE(01)',
' ' 'BDC_OKCODE' '=NEWL'.
PERFORM f_set_bdc_val
USING :
'1' 'SAPLZVSHIP_TRAK' '0002',
' ' 'BDC_CURSOR' 'ZVSHIP_TRK_DATA-TRACKN',
' ' 'ZVSHIP_TRK_DATA-TRACKN' wa_upload-field2,
' ' 'BDC_OKCODE' '/00'.
PERFORM f_set_bdc_val
USING :
'1' 'SAPLZVSHIP_TRAK' '0002',
' ' 'ZVSHIP_TRK_DATA-EOD_DATE' loc_pickupdate,
' ' 'ZVSHIP_TRK_DATA-ACT_DATE' wa_upload-field25.
IF NOT wa_upload-field15 IS INITIAL.
PERFORM F_SET_BDC_VAL
USING :
' ' 'ZVSHIP_TRK_DATA-PKG_WGT' wa_upload-field15. "Total Wt.
ENDIF.
PERFORM f_set_bdc_val
USING :
' ' 'ZVSHIP_TRK_DATA-ACT_FRT' wa_upload-field20,"Total Net charges
' ' 'ZVSHIP_TRK_DATA-ACT_SURCH' wa_upload-field18,"Fuel surcharge
' ' 'ZVSHIP_TRK_DATA-ACT_ACC' wa_upload-field19, "Accessorial ch.
' ' 'ZVSHIP_TRK_DATA-ACT_TOTAL' wa_upload-field16,"Gross Charges
' ' 'ZVSHIP_TRK_DATA-ACT_PER_LB' loc_charprice. "Price/LB
IF NOT wa_upload-field13 IS INITIAL.
PERFORM F_SET_BDC_VAL
USING :
' ' 'ZVSHIP_TRK_DATA-PKG_PAL' wa_upload-field13. "Pallet count
ENDIF.
IF NOT wa_upload-field14 IS INITIAL.
PERFORM F_SET_BDC_VAL
USING :
' ' 'ZVSHIP_TRK_DATA-PKG_PCS' wa_upload-field14. "Case count
ENDIF.
PERFORM f_set_bdc_val
USING :
' ' 'BDC_OKCODE' '=SAVE'.
PERFORM f_set_bdc_val
USING :
'1' 'SAPLZVSHIP_TRAK' '0002',
' ' 'BDC_OKCODE' '=UEBE'.
PERFORM f_set_bdc_val
USING :
'1' 'SAPLZVSHIP_TRAK' '0001',
' ' 'BDC_OKCODE' '=BACK'.
call transaction ZVTRAFFICINPUT
PERFORM f_call_zvtrafficinput.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " f_upload_data
FORM F_SET_BDC_VAL *
--> WG_DYNBEGIN *
--> WF_FIELDNAME *
--> WF_FIELDVAL *
FORM f_set_bdc_val USING
locf_dynbegin
locf_fieldname
locf_fieldval.
CLEAR wa_bdcdata.
IF locf_dynbegin = wl_1. "'1'.
wa_bdcdata-program = locf_fieldname.
wa_bdcdata-dynpro = locf_fieldval.
wa_bdcdata-dynbegin = wl_x. "'X'.
ELSE.
wa_bdcdata-fnam = locf_fieldname.
wa_bdcdata-fval = locf_fieldval.
ENDIF.
APPEND wa_bdcdata TO int_bdcdata.
ENDFORM. "F_SET_BDC_VAL
*& Form F_CALL_ZVTRAFFICINPUT
text
--> p1 text
<-- p2 text
FORM f_call_zvtrafficinput .
DATA: locf_last_rec TYPE sy-index,
wf_msgstring(128) TYPE c.
DATA: loc_mode TYPE c.
loc_mode = 'N'. "+001 needs to be changed
CALL TRANSACTION wl_tcode
USING int_bdcdata
MODE 'A'
MODE wl_mode "In Backgrnd(N)
MODE loc_mode
UPDATE wl_update "(S)ynchr mode "+001
MESSAGES INTO int_messages.
In case there are errors in call transaction
IF sy-subrc <> 0.
DESCRIBE TABLE int_messages LINES locf_last_rec.
READ TABLE int_messages INTO wa_messages
INDEX locf_last_rec.
PERFORM f_fill_bdc_error USING wa_upload-field2 wf_msgstring.
ELSE.
Keep count of successfully process records
wf_recok = wf_recok + 1.
PERFORM f_fill_bdc_success USING wa_upload-field2.
ENDIF.
REFRESH: int_bdcdata, int_messages.
ENDFORM. " F_CALL_ZVTRAFFICINPUT
*& Form f_fill_bdc_success
text
-->P_WA_UPLOAD_FIELD2 text
FORM f_fill_bdc_success USING p_wa_upload_field2.
CONCATENATE wl_trackno p_wa_upload_field2 '- Entry added'
INTO
wa_error_data-errtext. "Success message
APPEND wa_error_data TO int_error_data.
ENDFORM. " f_fill_bdc_success
*& Form f_fill_bdc_error
text
-->P_WA_UPLOAD_FIELD2 text
-->P_WF_MSGSTRING text
FORM f_fill_bdc_error USING p_wa_upload_field2
p_wf_msgstring.
CONCATENATE wl_trackno p_wa_upload_field2
'- Error : ' p_wf_msgstring
INTO
wa_error_data-errtext. "Error text of int_error_data
APPEND wa_error_data TO int_error_data.
ENDFORM. " f_fill_bdc_error
*& Form f_display_report
text
FORM f_display_report.
*+001 Begin:
DATA: reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
doc_chng LIKE sodocchgi1,
objcont LIKE solisti1 OCCURS 0 WITH HEADER LINE.
DATA: loc_recnt(4) TYPE c,
loc_recok(4) TYPE c.
*+001 End:
if sy-batch ne wl_x. "+001
ULINE /1(175).
WRITE:/ 'Date/Time: '(006) COLOR COL_HEADING,
sy-datum DD/MM/YYYY, '/',sy-uzeit,
40 'Uploading of Carrier Information to ZVTRAFFIC'.
ULINE /1(175).
SKIP.
WRITE:/ 'Following File Has Been Processed'.
/ pa_file. "-001
SKIP.
WRITE:/ 'Number of records read:', wf_recnt.
WRITE:/ 'Number of records processed successfully:', wf_recok.
SKIP.
LOOP AT int_error_data INTO wa_error_data.
WRITE :/ wa_error_data-errtext.
ENDLOOP.
*+001 Begin:
ELSE.
IMPORT wf_file FROM MEMORY ID wl_id.
reclist-receiver = wl_adm.
reclist-rec_type = wl_u.
reclist-com_type = wl_int.
APPEND reclist.
doc_chng-obj_name = wl_urgent.
doc_chng-obj_descr = wl_descr.
CONCATENATE 'Date/Time: ' sy-datum '/' sy-uzeit
'Uploading of Carrier Information to ZVTRAFFIC'
INTO objcont SEPARATED BY space.
APPEND objcont.
*-001
CONCATENATE 'Following File Has Been Processed' pa_file
INTO objcont SEPARATED BY space.
APPEND objcont.
*-001
loc_recnt = wf_recnt.
CONCATENATE 'Number of records read:' loc_recnt
INTO objcont SEPARATED BY space.
APPEND objcont.
loc_recok = wf_recok.
CONCATENATE 'Number of records processed successfully:' loc_recok
INTO objcont SEPARATED BY space.
APPEND objcont.
LOOP AT int_error_data INTO wa_error_data.
MOVE wa_error_data-errtext TO objcont.
APPEND objcont.
ENDLOOP.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_type = wl_raw
document_data = doc_chng
put_in_outbox = wl_x
commit_work = wl_x
TABLES
object_content = objcont
receivers = reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
IF sy-subrc EQ 0.
MESSAGE s205. "email sent
ELSE.
MESSAGE i206. "email not sent
ENDIF.
ENDIF.
*+001 End:
ENDFORM. " f_display_report
*& Form f_background_job
text
--> p1 text
<-- p2 text
FORM f_background_job .
DATA: loc_jobcount LIKE btch1150-jobcount.
IF pa_backg = wl_x.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = wl_jobname
jobclass = 'A'
IMPORTING
jobcount = loc_jobcount
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE i000(zmmx) WITH 'JOB_OPEN failed.' 'sy-subrc =' sy-subrc.
LEAVE LIST-PROCESSING.
ENDIF.
CALL FUNCTION 'JOB_SUBMIT'
EXPORTING
extpgm_param = pa_file
authcknam = sy-uname
jobcount = loc_jobcount
jobname = wl_jobname
report = sy-repid
variant = wl_variant
EXCEPTIONS
bad_priparams = 1
bad_xpgflags = 2
invalid_jobdata = 3
jobname_missing = 4
job_notex = 5
job_submit_failed = 6
lock_failed = 7
program_missing = 8
prog_abap_and_extpg_set = 9
OTHERS = 10.
IF sy-subrc <> 0.
MESSAGE i000(zmmx) WITH 'JOB_SUMBMIT failed.' 'sy-subrc =' sy-subrc.
LEAVE LIST-PROCESSING.
ENDIF.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = loc_jobcount
jobname = wl_jobname
strtimmed = 'X'
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE i000(zmmx) WITH 'JOB_CLOSE failed.' 'sy-subrc =' sy-subrc.
LEAVE LIST-PROCESSING.
ELSE.
MESSAGE i000(zmmx) DISPLAY LIKE wl_i WITH 'Background job submitted'.
LEAVE LIST-PROCESSING.
wait up to 60 seconds.
STOP.
ENDIF.
ENDIF.
ENDFORM. " f_background_job
*& Form f_get_server_file
text
--> p1 text
<-- p2 text
FORM f_get_server_file .
CLEAR: wf_filename.
following function module display the list of application file and
directories in a pop up window
CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
IMPORTING
serverfile = wf_filename
EXCEPTIONS
canceled_by_user = 1
OTHERS = 2.
If the user press cancel button without selecting file name
then the file name will be initial and raise the error message
IF wf_filename IS INITIAL.
MESSAGE i000 WITH 'No File selected'(012).
LEAVE LIST-PROCESSING.
ENDIF.
pa_sfile = wf_filename.
ENDFORM. " f_get_server_file
*& Form f_move_file_to_other_dir
To move the
FORM f_move_file_to_other_dir USING locf_source_file
locf_dest_file.
CALL FUNCTION 'Z_FILE_HANDLING_UTILITY'
EXPORTING
action = wl_action "VALUE 'mov'
source_physical_file_name = locf_source_file
dest_physical_file_name = locf_dest_file
EXCEPTIONS
invalid_action = 1
invalid_file_type = 2
file_type_missing = 3
file_type_not_required = 4
source_file_missing = 5
source_filename_error = 6
destination_not_required = 7
destination_missing = 8
multiple_file_names = 9
file_deletion_error = 10
invalid_source_file = 11
file_read_error = 12
file_write_error = 13
file_rename_error = 14
file_move_error = 15
destination_file_exists = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE i000(zmmx) WITH 'Error in Moving Process directory to completed Directory'(004).
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " f_move_file_to_other_dir
*& Form f_get_path
text
--> p1 text
<-- p2 text
FORM f_get_path .
CALL FUNCTION 'RZL_READ_DIR_LOCAL'
EXPORTING
name = wf_path
TABLES
file_tbl = ifiles
EXCEPTIONS
argument_error = 1
not_found = 2
OTHERS = 3.
DELETE ifiles WHERE name+0(1) = '.'.
DELETE ifiles WHERE name+0(1) NE 'w'.
ENDFORM. " f_get_path
Regards,
Brahma Reddy -
OPEN DATASET FOR INPUT IN TEXT MODE - linesize issue
Hi,
I faced a problem when opened ANSI file with CYRILLIC in ECC 6.0 Unicode system - the system cuts the line to 250 characters. Below is snip of code:
REPORT Z_TEST_01 LINE-SIZE 1023.
DATA:
file TYPE char40 VALUE 'ansi_file.txt',
line TYPE char1024, len TYPE i.
OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
WHILE sy-subrc = 0.
READ DATASET file INTO line ACTUAL LENGTH len.
WRITE: / len, line.
ENDWHILE.
CLOSE DATASET file.
In this case, variable LEN always get value 250. File-content is correctly converted from ANSI and all CYRILLIC is displayed to the screen. I changed type for LINE - initialy the type was STRING, actially.
Further, tried to open it in BINARY - like this:
DATA:
file TYPE char40 VALUE 'ansi_file.txt',
line TYPE char1024, len TYPE i.
FIELD-SYMBOLS <hex_container> TYPE x.
OPEN DATASET file FOR INPUT IN BINARY MODE.
ASSIGN line TO <hex_container> CASTING.
DO.
READ DATASET file INTO <hex_container>.
IF sy-subrc = 0.
WRITE: / line.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET file.
WRITE: / line.
In this case I got bigger linesize (obviously 1024), but faced conversion issues - the file contains some CYRILLIC and it is messed. Played for few hours with conversions - using additions: IN LEGACY BINARY MODE... BIG/LITTLE ENDIAN, CODE PAGE... without success. So decided to ask...
Well, I searched SDN for a similar issue, but didn't found, except this one:
Re: OPEN DATASET STRING Problem
Could someone points me what am I doing wrong? How can I read my ANSI file with line-size more than 250 chars? Actually, in my case line size may vary up to 1800 chars. Further, afrer conversion and some validation, I should save it back to the AS.
Many thans in advance.
Regards,
Ivaylo MutafchievSorry for the noise - it is not an issue anymore.
Maybe you are looking for
-
So since a few months my iPod is starting to get on my nerves. Everytime I try to sync it, my iTunes freezes during the "Determing Tracks to Sync" step. Most of the time it takes a few minutes and then it cancels the sync. I have to sync my ipod atle
-
HI experts, I have a 8.8 PL13 customer using SBO Mailer. They are experiencing some error since day 1 after upgrading to this Patch level. They have email triggered by Alerts. However, this email is only sent once when this alert is triggered. Subseq
-
Broken link for WebLogicJMSPerformanceGuide.pdf
I am unable to download WebLogicJMSPerformanceGuide.pdf from the following link. http://dev2dev.bea.com/pub/a/2004/01/WL_JMS_Perform_GD.html Does any body have a different URL for this document?
-
Hi Guys I am new to SAP BW. I am trying to schedule an initial load but I end up getting the following error message. This is an extract from the dump. call function 'RSAN_LOGSYS_DETERMINE' destination g_dest exporting i_cli
-
Broken hinge on a Macbook Air - how to fix it?
Hi, I have a Macbook Air which has worked perfectly all this time, but a few days back one of the hinges broke. The system still works fine, but opening the lid seems to strain the body structure. Upon opening the bottom cover, I noticed that a wire