on 02-19-2014 3:45 PM
Hello Guru's of Scripting.
We have a requirement to download inspection lot information for 4500+ plants using transaction QA33. We cannot use all plants at a time to get result output. I would like to run this report in parts. example: 20 plants at a time.
QA33 screen with plant selection:
Multiple selection for plant:
Here is my code so far:
_______________________________________________________________________________________________________________________________**********************************************************************************************************************************************************************************
//Counter
Set V[i] 1
//Input file that contains more than 4500 plants
Parameter mat_file1 "C:\Documents and Settings\Desktop\ip2.txt"
//Intermediate file to copy 20 plants at a time
Parameter mat_file3 "C:\Users\Desktop\myfile.txt"
//create myfile.txt text file on C:\Users\Desktop\ location before running program
OpenFile "&U[mat_file3]" -Output
OpenFile "&U[mat_file1]"
label Read_File
ReadFile "&U[mat_file1]" C
if not Q[ok]
CloseFile "&U[mat_file1]"
CloseFile "&U[mat_file2]"
CloseFile "&U[mat_file3]"
Return "Job done!" "&U[mat_file1]"
endif
// loops
//1st loop to make sure the total no of records do not exceed 4500
If V[i<4500]
AppendFile "&U[mat_file3]" C
Set V[i] "&V[i]" + 1
//Checking to make sure we append only 20 plants at a time.
//These 20 plants are added to myfile.txt
if V[i=21]
//myfile has 20 file it goes to transaction qa33 screen
Goto next_step
endif
goto Read_File
endif
label next_step
//Deletes default values from selection fields
Set F[%_QL_ENSTD_%_APP_%-TEXT] ""
Set F[%_QL_ENSTD_%_APP_%-TO_TEXT] ""
Set F[Plant] ""
Set F[Maximum No. of Hits] ""
// Inspection Lot Selection
Screen RQEEAL10.1000
//Clicked on multiple selection button
Enter "=%043" // Multiple selection.6
// Multiple Selection for Order
Screen SAPLALDB.3000
//This is equivalent to clicking on delete button from multiple selection
Enter "/16" //delete contents
// Multiple Selection for Plant
Screen SAPLALDB.3000
//Copy 20 plants from myfile to text t1
Copytext fromFile="&U[mat_file3]" toText="t1"
//Copy those 20 plants from t1 to clipboard
Copytext fromText="t1" -toclipboard
//Next step is to click on paste icon on dynamic selection
Enter "/24" //copy from clipboard
// Multiple Selection for Material
Screen SAPLALDB.3000
Enter "/8"
// Inspection Lot Selection
Screen RQEEAL10.1000
Enter "/8" // Execute
// Display data for inspection lot: Worklist for Inspection Lots
Screen SAPLSLVC_FULLSCREEN.0500
Enter "/Menu=1,4,3" // Local file...
// Save list in file...
Screen SAPLSPO5.0110
Set R[Spreadsheet] "X"
Enter
// Display data for inspection lot: Worklist for Inspection Lots
Screen SAPLSFES.0200
Set F[DY_PATH] "C:\Users\Desktop"
Set F[DY_FILENAME] "temp.txt"
Enter "/7" // Extend
// Display data for inspection lot: Worklist for Inspection Lots
Screen SAPLSLVC_FULLSCREEN.0500
Enter "/3"
Set V[i] 1
//OpenFile "&U[mat_file3]" -Output
Set V[t2] ""
Copytext fromText="t2" toFile="C:\Users\Desktop\myfile.txt"
// Display data for inspection lot: Worklist for Inspection Lots
CloseFile "&U[mat_file3]" -Output
//Screen SAPLSLVC_FULLSCREEN.0500
// Enter "/nqa33"
goto Read_File
******************************************************************************************************************************************************************************____________________________________________________________________________________________________________________________
Problem part of the code:
Copytext fromFile="&U[mat_file3]" toText="t1"
Copytext fromText="t1" -toclipboard
Enter "/24" //copy from clipboard
When I debug this code ..I see empty value for t1 or clipboard.
I have tried several Copytext options but no solution so far.
Please help me with this issue.
GuiXT solution OR VBScript but I want it to be able to paste 20 values.
I really appreciate you'r time and effort in this regard.
SAP Krazy
I have below program that works like a charm.
This code utilizes "paste" button on multiple selection screen.
What does code do: I have 500+ plants in ip2.txt file. I read 20 plants at a time and write it to myfile.txt
cop.exe (AHK script cop.ahk converted to .exe) is used to copy myfile.txt to clipboard. Now that information is on clipboard you can use
paste function from SAP multiple selection window.
This makes entire process automated and no human intervention is needed.
___________________________________________________________________________________
Parameter mat_file1 "C:\Documents and Settings\Desktop\ip2.txt"
Set V[i] 1
OpenFile "&U[mat_file1]"
label restart
Parameter mat_file2 "C:\Documents and Settings\Desktop\myfile.txt"
OpenFile "&U[mat_file2]" -Output
label Read_File
ReadFile "&U[mat_file1]" C
if not Q[ok]
goto last_one
//CloseFile "&U[mat_file1]"
//CloseFile "&U[mat_file2]"
//Return "Results file generated" "&U[mat_file2]"
endif
if V[i<20] OR V[i=20]
AppendFile "&U[mat_file2]" C
Set V[i] "&V[i]" + 1
if V[i=21]
goto next
else
goto Read_File
endif
endif
label next
CloseFile "&U[mat_file2]"
start "C:\Guixt\cop.exe"
// INSPECTION LOT RECORD
Screen AQZZYQM_ISC=====YQM_QALS======.1000
Set F[%_SP$00002_%_APP_%-TEXT] ""
Set F[%_SP$00013_%_APP_%-TEXT] "01/01/1990"
Set F[%_SP$00013_%_APP_%-TO_TEXT] "01/01/2006"
Set F[%_%LAYOUT_%_APP_%-TEXT] "mylayout"
Enter "=%002" // Multiple selection.2
// Multiple Selection for Plant
Screen SAPLALDB.3000
Enter "/16"
// Multiple Selection for Plant
Screen SAPLALDB.3000
Enter "/24"
// Multiple Selection for Plant
Screen SAPLALDB.3000
Enter "/8"
// INSPECTION LOT RECORD
Screen AQZZYQM_ISC=====YQM_QALS======.1000
Enter "/Menu=1,3" // Execute in Background
// Background Print Parameters
Screen SAPLSPRI.0100
Enter "/13"
// Start Time
Screen SAPLBTCH.1010
Enter "=IMMD" // Immediate
// Start Time
Screen SAPLBTCH.1010
Enter "/11"
Set V[i] 1
goto restart
label last_one
CloseFile "&U[mat_file2]"
start "C:\Guixt\cop.exe"
// INSPECTION LOT RECORD
Screen AQZZYQM_ISC=====YQM_QALS======.1000
Set F[%_SP$00002_%_APP_%-TEXT] ""
Set F[%_SP$00013_%_APP_%-TEXT] "01/01/1990"
Set F[%_SP$00013_%_APP_%-TO_TEXT] "01/01/2006"
Set F[%_%LAYOUT_%_APP_%-TEXT] "mylayout"
Enter "=%002" // Multiple selection.2
// Multiple Selection for Plant
Screen SAPLALDB.3000
Enter "/16"
// Multiple Selection for Plant
Screen SAPLALDB.3000
Enter "/24"
// Multiple Selection for Plant
Screen SAPLALDB.3000
Enter "/8"
// INSPECTION LOT RECORD
Screen AQZZYQM_ISC=====YQM_QALS======.1000
Enter "/Menu=1,3" // Execute in Background
// Background Print Parameters
Screen SAPLSPRI.0100
Enter "/13"
// Start Time
Screen SAPLBTCH.1010
Enter "=IMMD" // Immediate
// Start Time
Screen SAPLBTCH.1010
Enter "/11" wait=5000 //-visible
CloseFile "&U[mat_file1]"
CloseFile "&U[mat_file2]"
//Return "Results file generated" "&U[mat_file2]"
____________________________________________________________________________________________________________________________
Highlighted in red is a AHK script converted into .exe
my cop.AHK file:
____________________________________________________________________________________________________________________________
Clipboard = ; Empty the clipboard
FileRead, Clipboard, C:\Users\Desktop\myfile.txt
;msgbox %Clipboard%
return
____________________________________________________________________________________________________________________________
Install AHK to convert .ahk to .exe using ahk2exe program.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi SAP Krazy,
apparently there are not so many users working with GuiXT. Therefore, my suggestion at this point:
//Counter
Set V[i] 1
//Input file that contains more than 4500 plants
Parameter mat_file1 "C:\Documents and Settings\Desktop\ip2.txt"
//Intermediate file to copy 20 plants at a time
Parameter mat_file3 "C:\Users\Desktop\myfile.txt"
//create myfile.txt text file on C:\Users\Desktop\ location before running program
OpenFile "&U[mat_file3]" -Output
OpenFile "&U[mat_file1]"
label Read_File
ReadFile "&U[mat_file1]" C
//if not Q[ok]
if V[C=]
CloseFile "&U[mat_file1]"
//CloseFile "&U[mat_file2]"
CloseFile "&U[mat_file3]"
goto next_step
//Return "Job done!" "&U[mat_file1]"
endif
// loops
//1st loop to make sure the total no of records do not exceed 4500
If V[i<4500]
AppendFile "&U[mat_file3]" C
Set V[i] "&V[i]" + 1
//Checking to make sure we append only 20 plants at a time.
//These 20 plants are added to myfile.txt
if V[i=21]
//myfile has 20 file it goes to transaction qa33 screen
Goto next_step
endif
goto Read_File
endif
label next_step
CloseFile "&U[mat_file3]"
//Deletes default values from selection fields
Set F[%_QL_ENSTD_%_APP_%-TEXT] ""
Set F[%_QL_ENSTD_%_APP_%-TO_TEXT] ""
Set F[Plant] ""
Set F[Maximum No. of Hits] ""
// Inspection Lot Selection
Screen RQEEAL10.1000
//Clicked on multiple selection button
Enter "=%043" // Multiple selection.6
// Multiple Selection for Order
Screen SAPLALDB.3000
//This is equivalent to clicking on delete button from multiple selection
Enter "/16" //delete contents
// Multiple Selection for Plant
Screen SAPLALDB.3000
//Copy 20 plants from myfile to text t1
Copytext fromFile="&U[mat_file3]" toText="t1"
//Copy those 20 plants from t1 to clipboard
Copytext fromText="t1" -toclipboard
//Next step is to click on paste icon on dynamic selection
Enter "/24" //copy from clipboard
// Multiple Selection for Material
Screen SAPLALDB.3000
Enter "/8"
// Inspection Lot Selection
Screen RQEEAL10.1000
Enter "/8" // Execute
// Display data for inspection lot: Worklist for Inspection Lots
Screen SAPLSLVC_FULLSCREEN.0500
Enter "/Menu=1,4,3" // Local file...
// Save list in file...
Screen SAPLSPO5.0110
Set R[Spreadsheet] "X"
Enter
// Display data for inspection lot: Worklist for Inspection Lots
Screen SAPLSFES.0200
Set F[DY_PATH] "C:\Users\Desktop"
Set F[DY_FILENAME] "temp.txt"
Enter "/7" // Extend
// Display data for inspection lot: Worklist for Inspection Lots
Screen SAPLSLVC_FULLSCREEN.0500
Enter "/3"
Set V[i] 1
//OpenFile "&U[mat_file3]" -Output
//Set V[t2] ""
//Copytext fromText="t2" toFile="C:\Users\Desktop\myfile.txt"
// Display data for inspection lot: Worklist for Inspection Lots
//CloseFile "&U[mat_file3]" -Output
//Screen SAPLSLVC_FULLSCREEN.0500
// Enter "/nqa33"
//goto Read_File
if not V[C=]
OpenFile "&U[mat_file3]" -Output
goto Read_File
endif
Return "Job is done!" "&U[mat_file1]"
CloseFile "&U[mat_file1]"
CloseFile "&U[mat_file3]"
A note: I saved my test file ip2.txt under ANSII code.
Regards,
ScriptMan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.