Adding a unique identifier in file name
Dear all,
In one of the scenario(n IDOCs to 1File),
IDOCs keep coming from SAP and at XI we are appending it in one file.
XI transmits this file on particular time of a day(say everyday at 6 PM) to the receiver system. It implies that it is a per day interface.
XI creates the file with the this convention: <DocName>>_<Date>.txt
Now a new requirement has come up to add a unique identifier to this filename for every transmission, Say for ex:
<UniqueIdentifier>_<DocName>_<Date>.txt
The receiver system wants this, UniqueIdentifier to be in sequence, say
0001_OrderData_20090224.txt
0002_OrderData_20090224.txt
Is it possible to achieve this in XI, Do we have any standard feature. or is there any workaround.
Kindly drop in your comments.
Thanks in advance,
Younus
Mohammed.
Your interface won't work like this. If this is the situation you want to archieve then you should use the IDOC.txt as a secondary input as well.
if you do an append on the file there is no way you can duplicate that.
else i'd suggest you create a CMD function which does a copy and append number to that. There is a function within SAP Xi to execute a CMD line function when done.
In this batch (or.sh) file you can copy the last file and append a number to that. Alllthough i'm not sure how dynamically that is.
greets
Similar Messages
-
I have a keynote presentation that i built a while ago. How do i now identify the file names of the video files that are in the presentation?
With your presentation open, click on each movie element and read the name in the Metrics Inspector > File Info.
-
Unique XML attatchment file name
Is there any way when an email submit button is pressed, the XML file name generated is unique every time.
The file name doesnt even need to relate to the data within the XML form, I could just be a set of random alpha numerics perhaps. I will be having almost 100 of these XML files ariving by email each day all to be put in the same folder/place on a windows PC so I need each one to have a unique name as maunaly renaming them will be very frustrating to do.
Any help appreciated.
Tom Bannister"You would think the program writers would have given an option to name the file after one of the field values that will be unique."
No kidding. I should have spent more time playing with the trial before I recommended purchase. Was hoping to have the attached file reflect a data field.
Like, in the form - Name: John
File attached to the e-mail 'John.xml'.
Seemed to me that there would be a way to script it. But it looks like not.
It looks like my solutions are to
A.) use Thunderbird with an attachment tool extension that will automatically re-name the files if they will overwrite when I go to save (sucks because Outlook is my required SW)
B.) do it in Outlook but rename and save the files individually. or
C.) ask my respondents to choose the "other" option when prompted to e-mail the data and then name the file according to my conventions.
I'm thinking 'A' is going to have to do.
But would like to see this feature added with an update. -
A script for adding the current date to file name?
I am working in Indesign CS3. I frequently save file as PDFs into a designated folder. I was hoping for help in writing a script that would apply the current date to the end of the file name, when saved into this folder. Some days, I save the same file several times, into this folder. I was also hoping there was a way to add a date and version, for example "filename_2.25.11(1).pdf" Is this possible? Can someone help me?
ok, I ended up with this test routine:
on adding folder items to this_folder after receiving added_items
tell application "Finder"
repeat with this in added_items
my checkifopened(this)
display dialog (name of this) as text
end repeat
end tell
end adding folder items to
on checkifopened(this)
set a to POSIX path of (this as alias)
repeat until 1 = 0
## don't like that one because it relies on an error msg ... so
(** try
set b to do shell script "lsof | grep " & quoted form of a
on error
exit repeat
end try**)
##so I use this one
set b to do shell script "lsof"
if b does not contain a then
exit repeat
else
say "still opened"
end if
end repeat
end checkifopened
this is a folder action that tests if the added file is still opened by an application... there is no delay between each test-loop since lsof takes some time to execute...
And after adding a timeout (just in case) to this function the final script looks like this:
on adding folder items to thefolder after receiving added_items
tell application "Finder"
set folderkind to kind of thefolder
set myfiles to every item of thefolder whose name does not contain "#" and kind is not folderkind
repeat with myfile in myfiles
set myfile_datestring to my get_datestring(creation date of myfile)
set myfilename to name of myfile
if (count of every character of myfilename) > 4 and (character -4 of myfilename) as text is "." then
set filestatus to my checkifopened(myfile, 60)
if filestatus = false then
display dialog "timeout on folder action"
else
set tmp to ((characters 1 through -5 of myfilename) & "#" & myfile_datestring & (characters -4 through -1 of myfilename)) as text
set myfilename to my checknamewith_pdfsuffix(tmp, thefolder, false)
set name of myfile to myfilename
end if
end if
end repeat
end tell
end adding folder items to
on get_datestring(mydate)
return year of mydate & "-" & (characters -2 through -1 of (("0" & (month of mydate as integer)) as text)) & "-" & (characters -2 through -1 of (("0" & (day of mydate as integer)) as text)) as text
end get_datestring
on checknamewith_pdfsuffix(n, D, looped)
--check if filename exists in D
-- so if "A File.pdf" exists it names it "A File 1.pdf","A File 2.pdf",...
#n = string of the filename
#D = file reference to the directory to check
#looped = boolean used for recursive loop...
tell application "Finder"
set thefiles to name of every item of (D as alias)
end tell
if thefiles contains n then
if looped = false then
set n to ((characters 1 through -5 of n) & "(1)" & (characters -4 through -1 of n)) as text
my checknamewith_pdfsuffix(n, D, true)
else
set tmp to (last word of ((characters 1 through -5 of n) as text) as integer)
set tmpcount to (count of characters of (tmp as text)) + 5
set tmp to tmp + 1
set n to ((characters 1 through (-1 * tmpcount) of n) & "(" & tmp & ")" & (characters -4 through -1 of n)) as text
my checknamewith_pdfsuffix(n, D, true)
end if
else
return n
end if
end checknamewith_pdfsuffix
on checkifopened(this, mytimeout)
## this file reference
## timeout in seconds
set a to POSIX path of (this as alias)
set startdate to current date
repeat until 1 = 0
## don't like that one because it relies on an error msg ... so
(** try
set b to do shell script "lsof | grep " & quoted form of a
on error
exit repeat
end try**)
##so I use this one
set b to do shell script "lsof"
if b does not contain a then
return true
else if ((current date) - startdate) > mytimeout then
return false
else
##say "still opened"
end if
end repeat
end checkifopened
to use this save this script in /Library/Scripts/Folder Action Scripts
and add this as a folder action to your folder...
The script processes all files inside that folder each time a new files is added... -
Adding a prefix to a file name if the prefix is not already there
I have a script that adds a prefix to a file name then moves the file from its source directory to a destination directory. The problem I am encountering is that if the destination directory is unavailable for any reason the file fails to move &
so remains in the source directory and then the next time the script runs the prefix gets added again so I sometimes end up with files that look like this:
"Prefix_Prefix_Prefix_Prefix_Prefix_Prefix_1234_20141020_9786_8404.tif"
I need to build in some kind of logic that prevents this from happening so that if the Prefix_ is there it doesn't add it again, but not I'm not sure what the best way to do this is. Here is the code that adds the prefix.
Get-ChildItem $Source\* -include *.jpg,*.tif,*.pdf -exclude *.log | % {Rename-item $_.Fullname ("Prefix_" + $_.Name)}
# When I wrote this script only God and I knew what I was doing. # Now, only God Knows!Another option, but I like Bill's better:
$prefix = 'prefix'
Get-ChildItem | ForEach {
If ($_.Name -notlike "$prefix*") {
Rename-Item -Path $_.FullName -NewName "$($prefix)_$($_.Name)"
Don't retire TechNet! -
(Don't give up yet - 13,085+ strong and growing) -
How to identify transport file name
Hello Experts,
I have one scenario that i need to transport to production.
Now the problem is this scenario is already migrated upto Quality XI just need to migrate to Production XI.
Our client is concern that if there will be some problem we want to revert back the whole scenario.
For that i thought that we can identify the file which we had transported from XIQ to XIP previously and save that somewhere.
If there will be problem again then we can again import that file.
But i am not able to understand that how can i identify that file for that perticular scenario, as it is with numbers.
Please help me out in that.
Thanks in advance.
HetalHi,
you can check the exported object file name from Tools-->find Trasports option.
it is better to add your export files to a Transport Request in ABAP stack, which will keep you track of all the files which were transported.
??But i am not able to understand that how can i identify that file for that perticular scenario, as it is with numbers.
--> i think you are checking the Transport ID number not the file name.
check it from Find transports menu. it will give clear details.
Regards,
Sukarna -
Identifying text file names and importing on single Excel sheet
Hey!
Does anybody can help me with Excel VBA macro code in order to import data from text files into single Excel spread sheet? I want to create User Form where user can select start and end date of interest and macro code will import
bunch of text files depending on user demands...
My text files are named: 20130619004948DataLog.txt (meaning: yyyy mm dd hh mm ss). Text file contains recordings for each 15 seconds... It would be great to omit time tail (meaning that user can only specify date). Text files for one day of interest (I have
text files covering whole year):
20130619004948DataLog.txt
20130619014948DataLog.txt
20130619024948DataLog.txt
20130619034948DataLog.txt
20130619044948DataLog.txt
20130619054948DataLog.txt
20130619064948DataLog.txt
20130619074948DataLog.txt
20130619084948DataLog.txt
20130619094948DataLog.txt
20130619104948DataLog.txt
20130619114948DataLog.txt
20130619124948DataLog.txt
20130619134948DataLog.txt
20130619144948DataLog.txt
20130619154948DataLog.txt
20130619164948DataLog.txt
20130619174948DataLog.txt
20130619184948DataLog.txt
20130619194948DataLog.txt
20130619204948DataLog.txt
20130619214948DataLog.txt
20130619224948DataLog.txt
20130619234948DataLog.txt
Option Explicit
Sub SearchFiles()
Dim file As Variant
Dim x As Integer
Dim myWB As Workbook
Dim WB As Workbook
Dim newWS As Worksheet
Dim L As Long, t As Long, i As Long
Dim StartDateL As String
Dim EndDateL As String
Dim bool As Boolean
bool = False ' to check if other versions are present
StartDateL = Format(Calendar1, "yyyymmdd")
EndDateL = Format(Calendar2, "yyyymmdd")
' I am using Userform asking user to select the date and time range of interet,
' However, I want to use only the date to filter the files having the name with that particular date
file = Dir("c:\myfolder\") ' folder with all text files
' I need assistance with the following part:
'1) How to filter and select the files between StartDateL and EndDateL_
'(including files with that dates as well)?
While (file <> "")
If InStr(file, StartDateL) > 0 Then 'Not sure if the statements inside parenthesis is correct
bool = True
GoTo Line1:
End If
file = Dir
Wend
Line1:
If Not bool Then
file = "c:\myfolder\20130115033100DataLog.txt" 'Just for a test that the code works as intended
End If
'This part for the selected text files to be loaded on a single Excel Sheet.
Set myWB = ThisWorkbook
Set newWS = Sheets(1)
L = myWB.Sheets(1).Cells(Rows.Count, "A").End(xlUp).Row
t = 1
For x = 1 To UBound(file)
Workbooks.OpenText Filename:=file(x), DataType:=xlDelimited, Tab:=True, Semicolon:=True, Space:=False, Comma:=False
Set WB = ActiveWorkbook
WB.Sheets(1).UsedRange.Copy newWS.Cells(t, 2)
t = myWB.Sheets(1).Cells(Rows.Count, "B").End(xlUp).Row + 1
WB.Close False
Next
myWB.Sheets(1).Columns(1).Delete
Application.ScreenUpdating = False
Rows("1:1").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End Sub- Make a new Excel file
- Open the VBA editor
- Add a Userform
- Place 2 text boxes and 1 command button on that form
- Paste all code below into the code module of the form
- Download this file:
https://dl.dropboxusercontent.com/u/35239054/FileSearch.cls
- In the VBA editor press CTRL-M and import that file
- Save the Excel file in the directory that contain your text files
- Run the form
You can format the columns of the sheet as you like, e.g. column E:H should be a number with 5 decimal places. The top row can contain some headings. My code did not affect the formatting or the headings.
Andreas.
Option Explicit
Private Sub UserForm_Initialize()
'Just a sample
Me.TextBox1.Value = FormatDateTime(Now, vbGeneralDate)
Me.TextBox2.Value = FormatDateTime(Now, vbShortDate)
End Sub
Private Sub CommandButton1_Click()
Dim StartDate As Date, EndDate As Date
Dim FS As New FileSearch
Dim R As Range
Dim ThisFile As Variant
Dim ThisDate As Date
Dim Data As Variant
Dim Count As Long
'Be sure we have 2 dates
If Not IsDate(Me.TextBox1.Value) Then
Me.TextBox1.SetFocus
MsgBox "No start date"
Exit Sub
End If
If Not IsDate(Me.TextBox2.Value) Then
Me.TextBox2.SetFocus
MsgBox "No end date"
Exit Sub
End If
'Convert to real dates
StartDate = CDate(Me.TextBox1.Value)
EndDate = CDate(Me.TextBox2.Value)
'Time part given?
If Fix(EndDate) = EndDate Then
'No include all files for this day
EndDate = EndDate + TimeSerial(23, 59, 59)
End If
'Correct order?
If StartDate > EndDate Then
ThisDate = EndDate
EndDate = StartDate
StartDate = ThisDate
End If
With FS
'Same path as our file
.LookIn = ThisWorkbook.Path
.FileName = "*DataLog.txt"
'Search all files sort by file name
If .Execute(msoSortByFileName, msoSortOrderAscending) = 0 Then
MsgBox "No data files found in " & .LookIn
Exit Sub
End If
'Clear previous data
Set R = Range("A2").CurrentRegion
If R.Row < 2 Then Set R = R.Offset(1)
R.ClearContents
'Show the user that we are working
Application.Cursor = xlWait
DoEvents
For Each ThisFile In .FoundFiles
'Get the date from the file name
ThisDate = Filename2Date(ThisFile)
'Between our dates?
If (ThisDate >= StartDate) And (ThisDate <= EndDate) Then
'Import at the end of the data
Set R = Range("A" & Rows.Count).End(xlUp).Offset(1)
Data = ReadCSV(ThisFile)
R.Resize(UBound(Data) + 1, UBound(Data, 2) + 1) = Data
Count = Count + 1
End If
Next
End With
'Done
Application.Cursor = xlDefault
If Count = 0 Then
MsgBox "No files match your dates"
Else
MsgBox Count & " files imported"
'Hide the form
Me.Hide
End If
End Sub
Private Function Filename2Date(ByVal Fullname As String) As Date
'Convert e.g "C:\20130601142648DataLog.txt" to the date "01.06.2013 14:26:48"
Dim i As Long, j As Long
i = InStrRev(Fullname, "\")
If i > 0 Then Fullname = Mid(Fullname, i + 1)
Fullname = JustNumbers(Fullname)
If Len(Fullname) <> 14 Then Exit Function
Filename2Date = _
DateSerial(Mid(Fullname, 1, 4), Mid(Fullname, 5, 2), Mid(Fullname, 7, 2)) + _
TimeSerial(Mid(Fullname, 9, 2), Mid(Fullname, 11, 2), Mid(Fullname, 13, 2))
End Function
Private Function JustNumbers(ByVal What As String) As String
'Return only numbers from What (by Rick Rothstein)
Dim i As Long, j As Long, Digit As String
For i = 1 To Len(What)
Digit = Mid$(What, i, 1)
If Digit Like "#" Then
j = j + 1
Mid$(What, j, 1) = Digit
End If
Next
JustNumbers = Left$(What, j)
End Function
Private Function ReadCSV(ByVal Fullname As String) As Variant
'Read a CSV file into an array
Const LDelim = vbCrLf 'Line delimiter
Const FDelim = ";" 'Field delimiter
Dim hFile As Integer
Dim Buffer As String
Dim Lines, Line, Data
Dim i As Long, j As Long
'Be sure the file exists
If Dir(Fullname) = "" Then Exit Function
'Open and read all data
hFile = FreeFile
Open Fullname For Binary Access Read As #hFile
Buffer = Space(LOF(hFile))
Get #hFile, , Buffer
Close #hFile
'Split into lines
Lines = Split(Buffer, LDelim)
'Split the first line and prepare the output
'Note: I assume that all lines have the same number of fields
Line = Split(Lines(0), FDelim)
ReDim Data(0 To UBound(Lines), 0 To UBound(Line))
For i = 0 To UBound(Lines)
Line = Split(Lines(i), FDelim)
For j = 0 To UBound(Line)
'Parse the fields
If IsDate(Line(j)) Then
Data(i, j) = CDate(Line(j))
ElseIf IsNumeric(Line(j)) Then
Data(i, j) = CDbl(Line(j))
Else
Data(i, j) = Line(j)
End If
Next
Next
ReadCSV = Data
End Function -
Images added to page have wrong file name
I've been using iWeb ever since it came out and thought I knew everything I needed to know but am running into an unusual issue.
I have a folder of images I call my originals. I copy them and place them into another folder called large. I run an Automator action to scale the images down to 750, rename the images large-001aa.jpg and also create a corresponding thumbnail folder and files. When I drag and drop these images into iWeb, the older filenames are there. The filename in iWeb and the actual filename do not match. It's as if it's pulling up an older filename from when the image was first created. I have deleted the page, quit iWeb, etc. What's going on here? Is it pulling old metadata or is there a cache I need to clear? Thanks for any help.Youtube video of the issue. It has audio but don't know why youtube isnt playing it.
http://www.youtube.com/watch?v=yFU8XjWIkO4
Watch for when I add the image to iWeb. In finder it's small_001.jpg but after adding it to iWeb it's thumbnail... -
firefox is located on unix box and I would like to use it to open report generated. After script creats report I would like to call firefox to read report. "firefox report.htm"
I have solved this problem. All I needed was to follow firefox with the filename
-
Why is LR importing duplicate files and adding a -1 to file name?
I need to locate some missing photos that disappeared from my library so I'm re-importing my photo collection again (from burnt DVD's) in hopes to recover all the missing images. When I insert a DVD to re-import the photo collection and choose "convert to DNG" and I check "do not import suspected duplicates" LR imports the same images that are already in the catalog and renames the images with a -1...for example, IMG_3664.dng is already in LR folder named 2008-06-14. When I re-import the images from that date, LR renames the image IMG_3664-1.dng and puts it in the same folder resulting in duplicate images side by side. Why is it importing the same image and adding a -1 to the file name?
I was expecting it to tell me there are XXX photos already in the catalog but it doesn't. It just adds a -1 to the file name and imports all the duplicate images and displays them side by side in the grid view.
Any ideas? I originally imported the images from the same DVD's I'm using now on a PC and placed the library on an external hard drive. NOw I'm using a new iMAC and I imported that same library from the same external drive location. I'm working with LR 1.31.
Can someone help? LR should recognize the files with the identical date/time stamp and tell me it's already in the catalog...but it's not for some reason.
ThanksIf you import them again, you'll get a "-2" instead of -1, and the -2 will list with the -1,and the original with no dash. The higher number distinguishes the most recent file of same title..
The file titles are identical as original, but it sounds as converting the file from the source,(PC, Hard drive) to DNG makes it another version of the file....do you type DNG in caps? should it be lower case?
Because the computer doesn't read the file as a duplicate, but the file name is the same, you'll get a -1.
This could probably happen,say, if your files are raw, and you had burned them as jpeg onto dvd storage. Even though you want them back as raw, converting them isn't duplicating them.
I hope this helps...I don't even own Lightroom; I'm shopping around between this and Aperture right now...the experience I'm referring to is where I work in a pre-press printing house; So if someone replying to my post who masters in Lightroom calls me an idiot, I won't argue much!! -
When I download a file, if a file of similar name already exists in the same download folder, the firefox downloads the file and renames it by adding numeric .1 to the file name.
I want the firebox to give me a prompt that similar file already exist, rather than automatically renaming it by adding suffix .1.Downloads Options
* https://support.mozilla.com/en-US/kb/Options%20window%20-%20General%20panel#w_downloads
Unable to Download or Save files
* https://support.mozilla.com/en-US/kb/Unable%20to%20download%20or%20save%20files
Check and tell if its working. -
Identifying image and video file names in my presentation
I want to identify the file names of all the images and videos in my Keynote presentation so that I can re-assemble the presentation in Final Cut Pro . . . I thought that just using Inspector might give me the file names, but it only shows me what the image or video looks like, but not the file names.
My photo images are not in iPhoto (I don't use iPhoto), they're in various other folders.
Thank you.There are two ways to find file names of media used in Keynote:
1
for a few images, select the images on the slide
Inspector > Builds
click on more options
if there are no builds set up, choose an effect
the file name will display in the build order:
2
It is more usefull and easier to do the following:
right click the Keynote file and select Show Package Contents
all the images and QuickTime files will be listed
you can make a screen grab to make a note of the file names (in finder - command shift 4)
the files can be copied to a folder and imported into other applications for further work -
Dynamic file names on file based processing
Hi Experts
we are doing file to file scenario using file based processing not on message based ( No Reposiitory Objects - No mapping , no interface objects ).
we need to pickup the file name from the source directory and place it in the target directory with the same file names.
the source file name is added with the time stamp and client number,
Since there no mapping , we can't use the dynamic file concepts.
Please help me with the possible solutions
thnz for the help in advance.
Cheers
FaheemHi Faheem,
You will be using the dynamic config when u want to map the input file name to a field in the target message.
As per ur requirement ASMA will do :
try this:
In both the sender and receiver file adapters , select Adapter Specific Identifiers and File Name
In the receiver file adapter give some dummy value for file name and directory.
In the runtime, the source file name and directory will be used as the target file name and directory.
You need not use any UDF or a mapping here
Hope it helps!!!!!!!! -
Hi All,
Can I create file name like tes1.txt.TimeStamp.pgp.
TimeStamp should be Dyanamic and I think we can get from Add Time stamp option in Reciever File adapter.
I normally see if we go for option Add Time Stamp, this timestamp will be added at the last of file name like test1.txt.pgp timestamp. If I want to get time stamp in middle of .txt and .pgp in file, How can we proceed?
Regards,
Chandra.customer is requesting for no '-' in time stamp
It is not possible to change the format of Timestamp feature of the channel.
You can add Timestamp in the Dynamic Config UDF itself and then create the filename as per your requirement.
What do we need to pass input for this UDF and do I need to have a field in target structure for it.
If you are intending to use the CurrentTime function in mapping then input to your UDF will be this function.
If you are implementing the logic in UDF itself, then the input can be any source node (even root node of source.....you wont be refering this node anywhere in the UDF then)
Similarly the O/P of the UDF can be mapped to any node on the target (even to target root node) as your UDF is not giving any value in return statement
Regards,
Abhishek.
Edited by: abhishek salvi on Dec 16, 2009 10:09 AM -
Capture the file name in the payload from the SOAP payload
Hi ,
We have a scenario , a file to RFC , we need the file name which is coming the SOAP payload . This file name needs to be captured in the payload . Please tell me is there any way capture this .
Thanks
AnitaAnita,
If SP14 and above , do this,
Sender File adapter --> Adapter Specific Identifiers --> Select File name
Then in your mapping, you can use this piece of code to access / get the file name,
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
String FileName = conf.get(key);
Regards,
Bhavesh
Maybe you are looking for
-
Backing up and restoring site definitions
Losing your site definitions in Dreamweaver can be a disaster, but it does happen sometimes. The best way to prepare for such an eventuality is to back up your site definitions on a regular basis. Creating a backup You can back up all your site defin
-
Google Chrome issue in LionOS - Mission Control
My Mac system version is Lion Mac OS X 10.7.2 (11C74) and Chrome is 16.0.912.63 9 (up to date). The problem is that every time I switch screens using Mission Control, Chrome comes together to the next space. It doesn't happen to Safari nor any other
-
How to find item is updating in Sharepoint designer workflow?
Is there anyway we can get when list item updating in sharepoint designer workflow?. I have status ="New" it is need to send only one time when new item created. But now it is sending emails when item is updating with status="New". So I want check if
-
What is the typical structure of an ABAP program?
-
Where can I get Red Hat Linux AS for Installing 10G
Hi, I am trying to install Oracle 10G on RedHat Linux 8.0 and the installer is existing with error message(Requires Redhat 2.1 or 3). Is RedHat 2.1 is free downloadable and could some one point the URL where I can download.