Issue regarding 0 truncation for numbers in .csv file
Hi
I m loading data from .csv file say: Item Master Data.
Our requirement is if customer sends item number as 0022 or 22 or 0001 or 1, we have to save & show same way.
Let us suppose customer send us data with item number u2018001u2019 but as he makes .csv file, I get as u20181u2019 and not u2018001u2019, So I could load as u20181u2019.
But if we rename customeru2019s csv file as .txt. And then open it in Excel with Item Number column as Text, we get '001'.
But every day we can't do it manually for every file, Pls let me know if you find any solution on this.....
Thanks...
Did you try what i said? try this in dev.create a dummy item infoobject of type char and build a flatfile datasource only with this infoobject. Use your CSV file. In the file delete all columns except item and try to preview and see whether leading zeros are visible? If you are able see 00 in .txt format then this should work. Try and let me know.
Edited by: Raghavendra Padmanaban on Feb 16, 2011 4:08 PM
Edited by: Raghavendra Padmanaban on Feb 16, 2011 4:09 PM
Similar Messages
-
How to approach for downloading a CSV file?
I'm running the following query and QoQ . Could you tell me how should I proceed for the "Download CSV" file option?
<!--- QoQ for FIRSTCONN --->
<cfquery datasource = "XX.XX.X.XX" name="master1">
SELECT STR_TO_DATE(date_format(Timedetail,'%m-%d-%Y'),'%m-%d-%Y') as FIRSTCONN
, COUNT(Timedetail) as FIRSTOccurances
, EVENTS
FROM MyDatabase
WHERE EVENTS = "FIRST"
GROUP BY FIRSTCONN ;
</cfquery>
<!--- Detail Query --->
<cfquery dbtype="query" name="detail1">
SELECT *
FROM master1
WHERE FIRSTCONN >= <cfqueryparam value="#form.startdate#" cfsqltype="cf_sql_varchar">
AND FIRSTCONN < <cfqueryparam value="#dateAdd('d', 1,form.enddate)#" cfsqltype="cf_sql_varchar">;
</cfquery>
<!--- QoQ for SECONDCONN --->
<cfquery datasource = "XX.XX.X.XX" name="master2">
SELECT STR_TO_DATE(date_format(Timedetail,'%m-%d-%Y'),'%m-%d-%Y') as SECONDCONN
, COUNT(Timedetail) as SECONDOccurances
, EVENTS
FROM MyDatabase
WHERE EVENTS = "SECOND"
GROUP BY SECONDCONN ;
</cfquery>
<cfquery dbtype="query" name="detail2">
SELECT *
FROM master2
WHERE SECONDCONN >= <cfqueryparam value="#form.startdate#" cfsqltype="cf_sql_varchar">
AND SECONDCONN < <cfqueryparam value="#dateAdd('d', 1,form.enddate)#" cfsqltype="cf_sql_varchar">;
</cfquery>
<cfchart format="flash" chartwidth="1000" chartheight="500" scalefrom="0" scaleto="50000" xAxisTitle="Dates" yaxistitle="Number of Connections">
<cfchartseries query="detail1" type="line" itemColumn="FIRSTCONN" valueColumn="FIRSTOccurances" >
<cfchartseries query="detail2" type="line" itemColumn="SECONDCONN" valueColumn="SECONDOccurances" >
</cfchartseries>
</cfchart>
The cfform code I'm using is as follows:
<cfform format="flash" preloader ="false">
<cfformgroup type="horizontal">
<cfinput type="dateField" name="startdate" label="Start Date" width="100" value="#form.startdate#">
<cfinput type="dateField" name="enddate" label="End Date" width="100" value="#form.enddate#">
<cfinput name="submitApply" type="submit" value = "Apply">
<cfinput name="cancel" type="submit" value="Download CSV">
</cfformgroup>
Desired Output:
I have attached the image for the output below. Please find it attached.
Basically, if a date range is 21June to 21 July. The output must be as shown in the image. (I have omitted THIRDCONN etc for the sake of simplicity in my code).
Please let me know how should I go about this problem and let me know if I can answer more questions.It's not built into the language. Your best bet is probably to put the CSV-Reading logic into its own class.
Or find one of the thousands of classes that already implement such a thing. -
Mapping issue: FCC: Idoc for each record in file
Hi,
I have file to Idoc scenario.
I receive csv file with multiple records.
The requirement is to create an Idoc for each record.
For eg.
source file
A1,B1,C1
A2,B2,C2
A3,B3,C3
After FCC
<MT>
<TRANS>
<ROW>
<A>A1</A>
<B>B1</B>
<C>C1</C>
</ROW>
<ROW>
<A>A2</A>
<B>B2</B>
<C>C2</C>
</ROW>
<ROW>
<A>A3</A>
<B>B3</B>
<C>C3</C>
</ROW>
</TRANS>
<MT>
I have first tested it with only 1 record to test end to end connectivity. It works as expected and Idoc is posted to target system.
Now when I am trying to send multiple records, I am getting some issues.
Below are the steps that I have taken to process multiple records:
1. Changed the cardinality of ROW (child of RecordSet) from 1 to Unbounded.
2. Changed the occurance of Idoc to Unbounded.
3. Mapped ROW to Idoc root.
I have tested the mapping in IR and it generates multiple IDOCs.
When I send the test file, it fails with error Tag found instead of tag IDOC BEGIN=
I can see the xml message created with multiple ROWs in XI by File adapter in sxmb_moni.
When I do Test Configuration in ID, with the XML message extracted from sxmbmoni, the result that I got was:_
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge"><ns0:Message1></ns0:Message1></ns0:Messages>
This means that idoc was not created while mapping.
But the same sample message works OK in IR!
Pls help where I have missed.
Regards,
Anirudh.Sudhir,
Thanks for your response.
FCC is working fine. I have taken the XML message in XI created after FCC from csv sample message.
I have tested this message in IR by placing it between
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
<ns0:Message1>
</ns0:Message1>
</ns0:Message>
It is working fine and Idocs are created in mapping in IR.
But the same sample message is creating below output ID!
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge"><ns0:Message1></ns0:Message1></ns0:Messages>
Regards,
Anirudh. -
Error for the uploading csv file to database
Hi i tried to upload the csv file to database and i am getting error as
<cffile action="read" file="#data_dir_upload#/di_audit_corp_upc_ldr_tbl.csv" variable="di_audit_corp_upc_ldr_tbl">
<!--- loop through the CSV-TXT file on line breaks and insert into database --->
<cfloop index="index" list="#di_audit_corp_upc_ldr_tbl#" delimiters="#chr(10)##chr(13)#">
<cfquery datasource="#request.dsnCAO#">
<!--- SET ANSI_WARNINGS OFF --->
INSERT INTO [dbo].[di_audit_corp_upc_ldr_tbl]
( cpt_dpt_cd,cpt_com_cd,sub_com_cd,con_upc_no,pid_lng_dsc_tx,pid_sht_dsc_tx)
VALUES
(<cfqueryparam value='#left(trim(listgetAt('#index#',2,',')),2)#' cfsqltype="cf_sql_char">,
<cfqueryparam value='#left(trim(listgetAt('#index#',3,',')),3)#' cfsqltype="cf_sql_char">,
<cfqueryparam value='#left(trim(listgetAt('#index#',4,',')),5)#' cfsqltype="cf_sql_char">,
<cfqueryparam value='#left(trim(listgetAt('#index#',1,',')),13)#' cfsqltype="cf_sql_varchar">,
<cfqueryparam value='#left(trim(listgetAt('#index#',5,',')),25)#' cfsqltype="cf_sql_varchar">,
<cfqueryparam value='#left(trim(listgetAt('#index#',6,',')),12)#' cfsqltype="cf_sql_varchar">)
</cfquery>
</cfloop>
Error:
An error occurred while executing DTS package to import data.
Invalid list index 6.
In function ListGetAt(list, index [, delimiters]), the value of index, 6, is not a valid as the first argument (this list has 5 elements). Valid indexes are in the range 1 through the number of elements in the list.
i am unable to solve this issue can any one will help me to solve this issue
Thanks,
KiranI take it your are trying to use a csv file to insert new data into a database, using flex and coldfusion?
if so, then I would load the file in flex using cffile in ColdFusion and then use Load Data if you are using MySQL
This can show you more about it.
http://blog.tygate.com/?p=75
We get very large csv files ftp'd to us every week, and we have to load them in to the db. this works for us. -
Example for loading a csv file into diadem from a labview application
Hi everyone, i'm using labview 8.2 and DIAdem 10.1.
I've been searching in NI example finder but I had no luck so far.
I have already downloaded the labview connectivity VIs.
Can anyone provide a example that can help me loading a csv file into diadem from a labview application?
ThanksHi Alexandre.
I attach an example for you.
Best Regards.
Message Edité par R_Duval le 01-15-2008 02:44 PM
Romain D.
National Instruments France
#adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
NIDays 2010 : Conférence mondiale de l'instrumentation virtuelle
>>Détails et Inscription<<
Attachments:
Classeur1.csv 1 KB
Load CSV to Diadem.vi 15 KB -
Crystal Reports for Eclipse - Using .csv files?
I recently installed crystal reports for Eclipse and much of the basic CR functionality seems to be there, but then I added a .csv file as an ODA flat file data source and I can see it in my "Data Source Explorer", but can not seem to drag it into my report to actually use the data. Am I missing some basic step?
Thanks,
ChrisHello Chris,
I recommend to post this query to the [Crystal Reports Design|SAP Crystal Reports; forum.
This forum is dedicated to topics related to the creation and design of Crystal Report documents. This includes topics such as database connectivity, parameters and parameter prompting, report formulas, record selection formulas, charting, sorting, grouping, totaling, printing, and exporting but also installation and registering.
It is monitored by qualified technicians and you will get a faster response there.
Also, all Crystal Reports Design queries remain in one place and thus can be easily searched in one place.
Best regards,
Falk -
Issues while opening a UTF16 encoded .csv file in excel using c#
When I tried to open a UTF8 encoded
.csv file in excel through my c# code, doing something like this:
m_excel.Workbooks.OpenText(newPath, Comma: true);
That works fine. Can anyone tell me what to do if I had to open a UTF16 encoded
.CSV file similarly. All options i tried either fails or print incorrect Unicode characters.
So somehow we have to specify the encoding format (of the file to be opened i.e .CSV) while opening using excel functions, which i am unable to figure out.
Please help me. I am badly stuck here.
Thanks in advance.Hi Jb9952,
There is an Origin parameter in
Workbooks.OpenText method, you need to specify this parameter. You could try to use xlWindows (Windows ANSI).
To get the specify file origin value, you could get the detail code through Record Macro feature in excel.
Regards
Starain
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
How to use GUI_upload for Uploading a CSV file in Microsoft Excel.
Hi Guys,
can anybody tell me how to Upload the CSV format file in Microsoft excel sheet?
Thanks,
Gopi.Hi Gopi,
u can use GUI_UPLOAD, TEXT_CONVERT_XLS_TO_SAP.
Please check these codes.
Uploading data from CSV file format into internal table using GUI_UPLOAD
REPORT zupload MESSAGE-ID bd.
DATA: w_tab TYPE ZTEST.
DATA: i_tab TYPE STANDARD TABLE OF ZTEST.
DATA: v_subrc(2),
v_recswritten(6).
PARAMETERS: p_file(80)
DEFAULT 'C:\Temp\ZTEST.TXT'.
DATA: filename TYPE string,
w_ans(1) TYPE c.
filename = p_file.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = 'Upload Confirmation'
* DIAGNOSE_OBJECT = ' '
text_question = p_file
text_button_1 = 'Yes'(001)
* ICON_BUTTON_1 = ' '
text_button_2 = 'No'(002)
* ICON_BUTTON_2 = ' '
default_button = '2'
* DISPLAY_CANCEL_BUTTON = 'X'
* USERDEFINED_F1_HELP = ' '
* START_COLUMN = 25
* START_ROW = 6
* POPUP_TYPE =
* IV_QUICKINFO_BUTTON_1 = ' '
* IV_QUICKINFO_BUTTON_2 = ' '
IMPORTING
answer = w_ans
* TABLES
* PARAMETER =
* EXCEPTIONS
* TEXT_NOT_FOUND = 1
* OTHERS = 2
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CHECK w_ans = 1.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename
* FILETYPE = 'ASC
has_field_separator = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
data_tab = i_tab
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.
* SYST FIELDS ARE NOT SET BY THIS FUNCTION SO DISPLAY THE ERROR CODE *
IF sy-subrc <> 0.
v_subrc = sy-subrc.
MESSAGE e899 WITH 'File Open Error' v_subrc.
ENDIF.
INSERT ZTEST FROM TABLE i_tab.
COMMIT WORK AND WAIT.
MESSAGE i899 WITH sy-dbcnt 'Records Written to ZTEST'.
Uploading data from Excel file format into internal table using TEXT_CONVERT_XLS_TO_SAP
REPORT zupload_excel_to_itab.
TYPE-POOLS: truxs.
PARAMETERS: p_file TYPE rlgrap-filename.
TYPES: BEGIN OF t_datatab,
col1(30) TYPE c,
col2(30) TYPE c,
col3(30) TYPE c,
END OF t_datatab.
DATA: it_datatab type standard table of t_datatab,
wa_datatab type t_datatab.
DATA: it_raw TYPE truxs_t_text_data.
* At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
*START-OF-SELECTION.
START-OF-SELECTION.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_file
TABLES
i_tab_converted_data = it_datatab[] "ACTUAL DATA
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* END-OF-SELECTION.
END-OF-SELECTION.
LOOP AT it_datatab INTO wa_datatab.
WRITE:/ wa_datatab-col1,
wa_datatab-col2,
wa_datatab-col3.
ENDLOOP.
reward if helpful
raam -
Issue regarding bdc for capturing error records
Hi All,
My requirement is to capture the error record and download the error record to a flat file .
I have done recording for MM01 transaction .
I am getting a problem like no error records are downloaded into the flat file .It is downloading only the empty records.
Pls see the below code which i developed & modify it for any changes .Its an urgent .Pls provide me the solution ASAP.
My Flat file
M FERT X MATL105 KG
X FERT X MATL106 KG
In the above flat file 'X' is an Industry sector which doesnot exists which is an error record that has to be captured and download it into the flat file .
Source code :
report Z_MM01_MSG_F MESSAGE-ID MSG1
no standard page heading line-size 255.
include bdcrecx1.
parameters: dataset(132) lower case.
*** DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
* If it is nessesary to change the data section use the rules:
* 1.) Each definition of a field exists of two lines
* 2.) The first line shows exactly the comment
* '* data element: ' followed with the data element
* which describes the field.
* If you don't have a data element use the
* comment without a data element name
* 3.) The second line shows the fieldname of the
* structure, the fieldname must consist of
* a fieldname and optional the character '_' and
* three numbers and the field length in brackets
* 4.) Each field must be type C.
*** Generated data section with specific formatting - DO NOT CHANGE ***
data: begin of record occurs 0,
* data element: MBRSH
MBRSH_001(001),
* data element: MTART
MTART_002(004),
* data element: XFELD
KZSEL_01_003(001),
* data element: MAKTX
MAKTX_004(040),
* data element: MEINS
MEINS_005(003),
* data element: MTPOS_MARA
MTPOS_MARA_006(004),
end of record.
*DECLARATION OF BDCDATA STRUCTURE
DATA: IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE .
*declaration to store the message
DATA: IT_MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE .
*DECLARATION TO STORE THE MESSAGE
DATA: BEGIN OF IT_STORE_MSG OCCURS 0,
STORE(1000),
END OF IT_STORE_MSG.
*declaration SUCCESS MESG
DATA: BEGIN OF IT_SUCCESS OCCURS 0,
SUCCESS_REC(10),
MBRSH(10),
TABIX LIKE SY-TABIX,
END OF IT_SUCCESS.
*declaration ERROR MESSAGE
DATA: BEGIN OF IT_ERROR OCCURS 0,
ERROR_REC(10),
MBRSH(10),
TABIX LIKE SY-TABIX,
END OF IT_ERROR.
DATA:TABIX LIKE SY-TABIX.
*validating Material type(mtart) field data with table T134
data : v_type like T134-mtart.
DATA: V_INDSECT LIKE MARA-MBRSH.
*** End generated data section ***
start-of-selection.
CALL FUNCTION 'UPLOAD'
* EXPORTING
* CODEPAGE = ' '
* FILENAME = ' '
* FILETYPE = ' '
* ITEM = ' '
* FILEMASK_MASK = ' '
* FILEMASK_TEXT = ' '
* FILETYPE_NO_CHANGE = ' '
* FILEMASK_ALL = ' '
* FILETYPE_NO_SHOW = ' '
* LINE_EXIT = ' '
* USER_FORM = ' '
* USER_PROG = ' '
* SILENT = 'S'
* IMPORTING
* FILESIZE =
* CANCEL =
* ACT_FILENAME =
* ACT_FILETYPE =
TABLES
data_tab = record
* EXCEPTIONS
* CONVERSION_ERROR = 1
* INVALID_TABLE_WIDTH = 2
* INVALID_TYPE = 3
* NO_BATCH = 4
* UNKNOWN_ERROR = 5
* GUI_REFUSE_FILETRANSFER = 6
* OTHERS = 7
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*perform open_dataset using dataset.
perform open_group.
LOOP AT RECORD.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
*- Validating industry sector(MBRSH) from the master table(MARA)
select single MBRSH from T137 into V_INDSECT where MBRSH eq
record-MBRSH_001.
IF SY-SUBRC EQ 0.
perform bdc_field using 'RMMG1-MBRSH'
record-MBRSH_001.
*endif.
perform bdc_field using 'RMMG1-MTART'
record-MTART_002.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
record-KZSEL_01_003.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_004.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
record-MEINS_005.
perform bdc_field using 'MARA-MTPOS_MARA'
record-MTPOS_MARA_006.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_transaction using 'MM01'.
*ELSE.
*message E000 WITH 'Industry sector does not Exist' .
*endif.
LOOP AT MESSTAB.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = MESSTAB-MSGID
LANG = MESSTAB-MSGSPRA
NO = MESSTAB-MSGNR
V1 = MESSTAB-MSGV1
V2 = MESSTAB-MSGV2
* V3 = SY-MSGV3
* V4 = SY-MSGV4
IMPORTING
MSG = IT_STORE_MSG-STORE
EXCEPTIONS
* NOT_FOUND = 1
OTHERS = 0.
IF MESSTAB-MSGTYP = 'S'.
IT_SUCCESS-SUCCESS_REC = IT_STORE_MSG-STORE.
IT_SUCCESS-MBRSH = record-MBRSH_001.
IT_SUCCESS-TABIX = TABIX.
APPEND IT_SUCCESS.
ELSEIF MESSTAB-MSGTYP = 'E'.
IT_ERROR-ERROR_REC = IT_STORE_MSG-STORE.
IT_ERROR-MBRSH = record-MBRSH_001.
IT_ERROR-TABIX = TABIX.
APPEND IT_ERROR.
ENDIF.
endloop.
endif.
ENDLOOP.
CALL FUNCTION 'DOWNLOAD'
TABLES
DATA_TAB = IT_error
* FIELDNAMES =
* EXCEPTIONS
* INVALID_FILESIZE = 1
* INVALID_TABLE_WIDTH = 2
* INVALID_TYPE = 3
* NO_BATCH = 4
* UNKNOWN_ERROR = 5
* GUI_REFUSE_FILETRANSFER = 6
* OTHERS = 7
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
perform close_group.
*perform close_dataset using dataset.
Code Formatted by: Alvaro Tejada Galindo on Apr 9, 2008 5:05 PMHi,
DATA: IT_MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE .
CALL FUNCTION 'DOWNLOAD'
TABLES
DATA_TAB = IT_error
FIELDNAMES =
EXCEPTIONS
INVALID_FILESIZE = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7.
IF SY-SUBRC 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
instead of using IT_error ion tables use IT_MESSTAB.
<REMOVED BY MODERATOR>
Code Formatted by: Alvaro Tejada Galindo on Apr 9, 2008 5:07 PM -
Hi All,Issue regarding bdc for capturing error records,its urgent
Hi All,
My requirement is to capture the error record and download the error record to a flat file .
I have done recording for MM01 transaction .
I am getting a problem like no error records are downloaded into the flat file .It is downloading only the empty records.
Pls see the below code which i developed & modify it for any changes .Its an urgent .Pls provide me the solution ASAP.
My Flat file
M FERT X MATL105 KG
X FERT X MATL106 KG
In the above flat file 'X' is an Industry sector which doesnot exists which is an error record that has to be captured and download it into the flat file .
Source code :
report Z_MM01_MSG_F MESSAGE-ID MSG1
no standard page heading line-size 255.
include bdcrecx1.
parameters: dataset(132) lower case.
DO NOT CHANGE - the generated data section - DO NOT CHANGE ***
If it is nessesary to change the data section use the rules:
1.) Each definition of a field exists of two lines
2.) The first line shows exactly the comment
'* data element: ' followed with the data element
which describes the field.
If you don't have a data element use the
comment without a data element name
3.) The second line shows the fieldname of the
structure, the fieldname must consist of
a fieldname and optional the character '_' and
three numbers and the field length in brackets
4.) Each field must be type C.
Generated data section with specific formatting - DO NOT CHANGE ***
data: begin of record occurs 0,
data element: MBRSH
MBRSH_001(001),
data element: MTART
MTART_002(004),
data element: XFELD
KZSEL_01_003(001),
data element: MAKTX
MAKTX_004(040),
data element: MEINS
MEINS_005(003),
data element: MTPOS_MARA
MTPOS_MARA_006(004),
end of record.
*DECLARATION OF BDCDATA STRUCTURE
DATA: IT_BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE .
*declaration to store the message
DATA: IT_MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE .
*DECLARATION TO STORE THE MESSAGE
DATA: BEGIN OF IT_STORE_MSG OCCURS 0,
STORE(1000),
END OF IT_STORE_MSG.
*declaration SUCCESS MESG
DATA: BEGIN OF IT_SUCCESS OCCURS 0,
SUCCESS_REC(10),
MBRSH(10),
TABIX LIKE SY-TABIX,
END OF IT_SUCCESS.
*declaration ERROR MESSAGE
DATA: BEGIN OF IT_ERROR OCCURS 0,
ERROR_REC(10),
MBRSH(10),
TABIX LIKE SY-TABIX,
END OF IT_ERROR.
DATA:TABIX LIKE SY-TABIX.
*validating Material type(mtart) field data with table T134
data : v_type like T134-mtart.
DATA: V_INDSECT LIKE MARA-MBRSH.
End generated data section ***
start-of-selection.
CALL FUNCTION 'UPLOAD'
EXPORTING
CODEPAGE = ' '
FILENAME = ' '
FILETYPE = ' '
ITEM = ' '
FILEMASK_MASK = ' '
FILEMASK_TEXT = ' '
FILETYPE_NO_CHANGE = ' '
FILEMASK_ALL = ' '
FILETYPE_NO_SHOW = ' '
LINE_EXIT = ' '
USER_FORM = ' '
USER_PROG = ' '
SILENT = 'S'
IMPORTING
FILESIZE =
CANCEL =
ACT_FILENAME =
ACT_FILETYPE =
TABLES
data_tab = record
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*perform open_dataset using dataset.
perform open_group.
LOOP AT RECORD.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
*- Validating industry sector(MBRSH) from the master table(MARA)
select single MBRSH from T137 into V_INDSECT where MBRSH eq
record-MBRSH_001.
IF SY-SUBRC EQ 0.
perform bdc_field using 'RMMG1-MBRSH'
record-MBRSH_001.
*endif.
perform bdc_field using 'RMMG1-MTART'
record-MTART_002.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
record-KZSEL_01_003.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'MAKT-MAKTX'
record-MAKTX_004.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
record-MEINS_005.
perform bdc_field using 'MARA-MTPOS_MARA'
record-MTPOS_MARA_006.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_transaction using 'MM01'.
*ELSE.
*message E000 WITH 'Industry sector does not Exist' .
*endif.
LOOP AT MESSTAB.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = MESSTAB-MSGID
LANG = MESSTAB-MSGSPRA
NO = MESSTAB-MSGNR
V1 = MESSTAB-MSGV1
V2 = MESSTAB-MSGV2
V3 = SY-MSGV3
V4 = SY-MSGV4
IMPORTING
MSG = IT_STORE_MSG-STORE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 0.
IF MESSTAB-MSGTYP = 'S'.
IT_SUCCESS-SUCCESS_REC = IT_STORE_MSG-STORE.
IT_SUCCESS-MBRSH = record-MBRSH_001.
IT_SUCCESS-TABIX = TABIX.
APPEND IT_SUCCESS.
ELSEIF MESSTAB-MSGTYP = 'E'.
IT_ERROR-ERROR_REC = IT_STORE_MSG-STORE.
IT_ERROR-MBRSH = record-MBRSH_001.
IT_ERROR-TABIX = TABIX.
APPEND IT_ERROR.
ENDIF.
endloop.
endif.
ENDLOOP.
CALL FUNCTION 'DOWNLOAD'
TABLES
DATA_TAB = IT_error
FIELDNAMES =
EXCEPTIONS
INVALID_FILESIZE = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
perform close_group.
*perform close_dataset using dataset.Hi,
DATA: IT_MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE .
CALL FUNCTION 'DOWNLOAD'
TABLES
DATA_TAB = IT_error
FIELDNAMES =
EXCEPTIONS
INVALID_FILESIZE = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7.
IF SY-SUBRC 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
instead of using IT_error ion tables use IT_MESSTAB.
<REMOVED BY MODERATOR>
Code Formatted by: Alvaro Tejada Galindo on Apr 9, 2008 5:07 PM -
Question/issue regarding querying for uncommited objects in Toplink...
Hi, was hoping to get some insight into this problem we are encoutering
We have this scenario were we are creating a folder hierarchy (using Toplink)
1. a parent folder is created
2. child elements are created (in the same transaction as step 1),
3. we need to lookup the parent folder and assign it as the parent
of these child elements
4. end the transaction and commit all data
In our system we control access to objects by appending a filter to the selection criteria, so we end up with SQL like this example
(The t2 stuff is the authorization lookup part of the query.) ;
SELECT t0.ID, t0.CLASS_NAME, t0.DESCRIPTION, t0.EDITABLE,
t0.DATE_MODIFIED, t0.DATE_CREATED,
t0.MODIFIED_BY, t0.ACL_ID, t0.NAME, t0.CREATED_BY,
t0.TYPE_ID, t0.WKSP_ID, t1.ID, t1.LINK_SRC_PATH,
t1.ABSOLUTE_PATH, t1.MIME_TYPE, t1.FSIZE,
t1.CONTENT_PATH, t1.PARENT_ID
FROM XDOOBJECT t0, ALL_OBJECT_PRIVILEGES t2,
ARCHIVEOBJECT t1
WHERE ((((t1.ABSOLUTE_PATH = '/favorites/twatson2')
AND ((t1.ID = t2.xdoobject_id)
AND ((t2.user_id = 'twatson2')
AND (bitand(t2.privilege, 2) = 2))))
AND (t1.ID = t0.ID))
AND (t0.CLASS_NAME = 'oracle.xdo.server.repository.model.Archivable'))
When creating new objects we also create the authorization lookup record (which is inserted into a different table.) I can see all the objects are registered in the UOW identity map.
Basically, the issue is that this scenario all occurs in a single transaction and when querying for the newly created parent folder, if the authorization filter is appended to the query, the parent is not found. If I remove the authorization filter then the parent is found correctly. Or if I break this up into separate transactions and commit after each insert, then the parent is found correctly.
I use the conformResultsInUnitOfWork attribute on the queries.
This is related to an earlier thread I have in this discussion forum;
Nested UnitOfWork and reading newly created objects...
Thanks for any help you can provide,
-TimHi Doug, we add the authorization filter directly in the application code as the query is getting set up.
Here are some code examples; 1) the first is the code to create new object in the system, followed by 2) the code to create a new authorization lookup record (which also uses the first code to do the actual Toplink insert), then 3) an example of a read query where the authorization filter is appended to the Expression and after that 4) several helper methods.
I hope this is of some use as it's difficult to show the complete flow in a simple example.
1)
// create new object example
public Object DataAccess.createObject(....
Object result = null;
boolean inTx = true;
UnitOfWork uow = null;
try
SessionContext sc = mScm.getCurrentSessionContext();
uow = TLTransactionManager.getActiveTransaction(sc.getUserId());
if (uow == null)
Session session = TLSessionFactory.getSession();
uow = session.acquireUnitOfWork();
inTx = false;
Object oclone = (Object) uow.registerObject(object);
uow.assignSequenceNumbers();
if (oclone instanceof BaseObject)
BaseObject boclone = (BaseObject)oclone;
Date now = new Date();
boclone.setCreated(now);
boclone.setModified(now);
boclone.setModifiedBy(sc.getUserId());
boclone.setCreatedBy(sc.getUserId());
uow.printRegisteredObjects();
uow.validateObjectSpace();
if (inTx == false) uow.commit();
//just temp, see above
if (true == authorizer.requiresCheck(oclone))
authorizer.grantPrivilege(oclone);
result = oclone;
2)
// Authorizer.grantPrivilege method
public void grantPrivilege(Object object) throws DataAccessException
if (requiresCheck(object) == false)
throw new DataAccessException(
"Object does not implement Securable interface.");
Securable so = (Securable)object;
ModulePrivilege[] privs = so.getDefinedPrivileges();
BigInteger pmask = new BigInteger("0");
for (int i = 0; i < privs.length; i++)
BigInteger pv = PrivilegeManagerFactory.getPrivilegeValue(privs);
pmask = pmask.add(pv);
SessionContext sc = mScm.getCurrentSessionContext();
// the authorization lookup record
ObjectUserPrivilege oup = new ObjectUserPrivilege();
oup.setAclId(so.getAclId());
oup.setPrivileges(pmask);
oup.setUserId(sc.getUserId());
oup.setXdoObjectId(so.getId());
try
// this recurses back to the code snippet from above
mDataAccess.createObject(oup, this);
catch (DataAccessException dae) {
Object[] args = {dae.getClass().toString(), dae.getMessage()};
logger.severe(MessageFormat.format(EXCEPTION_MESSAGE, args));
throw new DataAccessException("Failed to grant object privilege.", dae);
3)
// example Query code
Object object = null;
ExpressionBuilder eb = new ExpressionBuilder();
Expression exp = eb.get(queryKeys[0]).equal(keyValues[0]);
for (int i = 1; i < queryKeys.length; i++)
exp = exp.and(eb.get(queryKeys[i]).equal(keyValues[i]));
// check if need to add authorization filter
if (authorizer.requiresCheck(domainClass) == true)
// this is where the authorization filter is appended to query
exp = exp.and(appendReadFilter());
ReadObjectQuery query = new ReadObjectQuery(domainClass, exp);
SessionContext sc = mScm.getCurrentSessionContext();
if (TLTransactionManager.isInTransaction(sc.getUserId()))
// part of a larger transaction scenario
query.conformResultsInUnitOfWork();
else
// not part of a transaction
query.refreshIdentityMapResult();
query.cascadePrivateParts();
Session session = getSession();
object = session.executeQuery(query);
4)
// builds the authorzation filter
private Expression appendReadFilter()
ExpressionBuilder eb = new ExpressionBuilder();
Expression exp1 = eb.getTable("ALL_OBJECT_PRIVILEGES").getField("xdoobject_id");
Expression exp2 = eb.getTable("ALL_OBJECT_PRIVILEGES").getField("user_id");
Expression exp3 = eb.getTable("ALL_OBJECT_PRIVILEGES").getField("privilege");
Vector args = new Vector();
args.add(READ_PRIVILEGE_VALUE);
Expression exp4 =
exp3.getFunctionWithArguments("bitand",args).equal(READ_PRIVILEGE_VALUE);
SessionContext sc = mScm.getCurrentSessionContext();
return eb.get("ID").equal(exp1).and(exp2.equal(sc.getUserId()).and(exp4));
// helper to get Toplink Session
private Session getSession() throws DataAccessException
SessionContext sc = mScm.getCurrentSessionContext();
Session session = TLTransactionManager.getActiveTransaction(sc.getUserId());
if (session == null)
session = TLSessionFactory.getSession();
return session;
// method of TLTransactionManager, provides easy access to TLSession
// which handles Toplink Sessions and is a singleton
public static UnitOfWork getActiveTransaction(String userId)
throws DataAccessException
TLSession tls = TLSession.getInstance();
return tls.getTransaction(userId);
// the TLSession method, returns the active transaction (UOW)
// or null if none
public UnitOfWork getTransaction(String uid) {
UnitOfWork uow = null;
UowWrapper uw = (UowWrapper)mTransactions.get(uid);
if (uw != null) {
uow = uw.getUow();
return uow;
Thanks!
-Tim -
Issue regarding sending E-Mail with PDF file(s) as attachment
Hi,
Can anybody provide me with code to send PDF file as E-Mail Attachment!
I know we have to use F.M <b>SO_NEW_DOCUMENT_ATT_SEND_API1</b> but how we have to use it to send PDF file as attachment!
I was able to send Text files as Attachments in my previous assignments.
Thanks in advance.
Thanks & Regards,
Kumar.Hi,
Check this threads:
SO_NEW_DOCUMENT_ATT_SEND_API1
unable to e-mail a pdf through FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'
SO_NEW_DOCUMENT_ATT_SEND_API1
Best regards,
Guillaume
Message was edited by: Guillaume Garcia -
String index out of bounds... issue regarding checking for non-integers
okay. i have been racking my brain about this for the last couple of days. i looks like everything is alright, but i keep getting string index out of bounds exception: string index out of range 1.
heres the code.
for(int x=0; x<size; ++x)
count=x+1;
System.out.println("Please enter value #"+count+(":"));
numnum=console.nextLine();
if(Character.isDigit(numnum.charAt(x)))
goodInput=true;
if(!goodInput)
System.out.print("Please Enter Only Integers!");
else
values[x]=Integer.parseInt(numnum);
its probably something really stupid, but if someone can figure this out, id be most grateful.
-thanksBe sure values contains data.
Then make sure that size = values.length
Either you don't have any data to iterate through, or the size variable is too big. So it's trying to search in parts of the array that don't exist. -
Zero is getting truncated while XI is creating a CSV file
Hi,
Scenario is IDOC to File.
in the IDOC i get some Serial number as 00000007856465 in the output CSV file i need this value as 07856465
Here when i run this map in the ESR Message mapping i could see 07856465 this value fine but while posting at the output directory the values are dropped with zeros truncated.
in the output CSV file -- the value is -- 7856465
Could you please help me out in solving this issue.
Thanks,
--Sai.Hi Sai Krishna,
As said by Bhaskar, use Formatnum function or UDF in your mapping. So that you would be able to get the 0's in the output.
I would prefer to go with FormatNum function.
Check the UDF provided by Raja Shekar in the below thread:
UDF for leading zero's in message mapping
Thanks, -
Searching for a data in a CSV file
i have my below code for reading a CSV file..
public static void main(String[] args)
ReadCSVFile obj = new ReadCSVFile();
try
BufferedReader in = new BufferedReader(new FileReader("RecordsNet DocType List1.csv"));
String str;
while ((str = in.readLine()) != null)
String s[] = str.split(",");
for (int i = s.length - 1; i >=0; i --)
System.out.println(s);
in.close();
catch (IOException e)
}//class main end
}// class ReadCSVFile end
i want to read my CSV file only if has some data in any column. how do i introduce this find clause while reading a CSV file
Please HelpYou could do something like this:
String[] s = str.split(",");
for (int i = (s.length - 1); i >= 0; i--)
if (s.length() > 0) // check if there is data in the column
System.out.print(s[i] + " ");
System.out.println();
Next time please paste your code between code tags exactly like this:
[code]
your code
[/code]
You may read the [url http://forum.java.sun.com/help.jspa?sec=formatting]Formatting tips for more information.
Regards
Maybe you are looking for
-
How to retrieve updated payload information from completed HumanTask
after initiating the HumanTask , updating the payload object from java client api payload information set into task object. taskService.updateTaskOutcome(workflowContext, task, outcome) ; after this call the HumanTask will be Completed. Now i tried t
-
Error in DTW for Special Prices while using
Hi All, while tryin to import Special prices through DTW, I'm gettin an error message, " No Price defined for item in selected price list". CAn anyone please suggest how to import special prices and whts the casue of this error?? Thanks in a
-
When I try to download OS X Mountain Lion from the app store I get the following message "An error occured while running scripts from the package "mzps8185591984996783701.pkg"." and will not progress past this point. Can any advise how to complete t
-
hi, i ve downloaded J2EE 1.4 sdk with sun application server. then i set environment variables as Classpath = D:\Sun\AppServer\lib;E:\Program Files\Java\jdk1.5.0_01\lib;E:\Program Files\Java\jre1.5.0_01\lib; j2ee_home = D:\Sun\AppServer; java_home =
-
How can i modify lable of texfield on create user page
Hi, How can i modify lable of texfield on create user page of oracle identity manager administrative console ? e.g. display Sponsor ID inplace of Manager ID Thanks