Internal table in background job
hi everyone
I have to process 4 internal tables to send to spool in background
HOw should the parameters be passed?
I have used the
SUBMIT /EU000/FI_PAYMENT TO SAP-SPOOL
SPOOL PARAMETERS mstr_print_parms
WITHOUT SPOOL DYNPRO.
but I dont know how I shd pass the internal tables
Plz help
Hi sia anjali.....
There is one concept in Spool Request,,, You can only produce a spool of a thing which you are writing....
for ex your report consist of 4 internal Tables,,, Then you can easily Produce a single spool request for all the 4 Internal tables with it's contents...
I am giving you the sample code for 2 Internal Tables.......... In this case you have to use two reports....
for ex.....
(1)- The first Report will only consist of the submit statement.....
REPORT ZTEST99 .
SUBMIT ztest100 TO SAP-SPOOL
DESTINATION 'LP01'
IMMEDIATELY ' '
KEEP IN SPOOL 'X'
WITHOUT SPOOL DYNPRO AND RETURN.
(2)- The second Report will consist of your internal tables that you want to display.......
*& Report ZTEST100 *
REPORT ZTEST100 .
data: begin of itab occurs 10.
include structure mseg.
data: end of itab.
data: begin of itab1 occurs 10.
include structure bseg.
data: end of itab1.
start-of-selection.
select * from mseg into table itab up to 10 rows.
select * from bseg into table itab1 up to 10 rows.
loop at itab.
write:/ itab-mblnr, itab-mjahr.
endloop.
uline.
loop at itab1.
write:/ itab1-bukrs, itab1-belnr.
endloop.
now this wil produce the spool request in SP01 T-code..........
If have any other queries do let me know......
Thanks
Saurabh
Similar Messages
-
Is it possible upload local file to internal table in background mode?
Hi, all,
Is it possbile to upload local file(not server file) to internal table in background mode.
If possbile ,please tell me detail . Thanks in advance.
Regards,
LilyHello,
This is possible.
If you report has to be executed in background using schedule Job. Then the file path should be constant and it can be hard coded in the report itself while populationg the internal table.
Then create a variant for your report and use that variant in the job.
This will solve your problem I guess.
Regards
Arindam -
FM????? Text file to Internal table in Background
Hi,
I need to execute my prog in background and as per my req i need to dwnload a file from prsentation server to internal table for processing. I'm not sure whch FM to use to dwnload from text file to internal table. I cannot use GUI_UPLOAD FM for background runs.....pls help
Thanks in advanceChesat,
You can not work for this requirement.You will have an idea on it.
Introduction
The use of FTP from ABAP seems to have been a hot topic on the ABAP Forums of late. I thought I might sit down and document whatever I could find on this subject and share it as a weblog.
Over the years I have seen lots of different solutions for moving files on and off of a SAP system. I have seen external FTP scripts written in OS shell languages. I have seen full blown custom applications that are made to interface to the SAP system. However I think you will find that most of the technology you need to perform a simple FTP from ABAP is already contained in the standard system. All of my examples and screen shots will be coming from a 46C system.
SAP's Solution
If you have ever taken a look at the kernel directory of your SAP system, you might have noticed an interesting little executable: sapftp.exe (the name of the file on Windows SAP Kernels). It is this part of the Kernel that exposes FTP functionality to the ABAP Programming language.
So you have a suspicion that there is FTP functionality in ABAP, but youre not quite sure how to use it. Where do you start? I always turn to the Service Marketplace first. A quick search on SAPFTP reveals there is an entire component (BC-SRV-COM-FTP) on the subject. The most general note and our starting place is OSS Note 93042. This note starts off with a nice description of what SAPFTP is: A client RFC application that is accessed via RFC from ABAP. But we also find out that in addition to SAPFTP being part of the kernel, it is also part of the SAPGui. That means that we can perform FTP commands originating from our R/3 Server or from a Client Workstation.
Well if this solution is accessed via RFC, then we must have to setup some RFC destinations. In fact we have two that we need; SAPFTP for Front-end FTP and SAPFTPA for access on the application server. Luckily we don't even have to mess with setting these RFC destinations up in SM59. SAP has supplied a program, RSFTP005, to generate the destinations for us.
Now before we go off and start written code on our own to hit these FTP functions, why don't we make sure everything is setup and working. Once again SAP has helped us out by providing us with a test program, RSFTP002. (In case you are wondering the FTP functionality and many other test programs are all contained in SAP Development Class SFTP). When we run this test, we get a set input parameters for the server, username password, etc. We want to start out simple and just make sure we are getting a connection. Therefore we will just execute the pwd command (Print Working Directory).
Your answer back should look something like this:
If you are wanting to see a list of FTP commands, try using the command HELP in place of PWD:
If something did go wrong during the test, I suggest that you active the trace option in SM59 for the FTP Destination. You can then use program RSFTP001 to display the current trace file.
Programming the FTP
Not only does the RSFTP002 program give us a test environment, but it also provides us with a programming example. We can see that the FTP functionality is really provided by a set of function modules all within the SFTP Function Group. We have the basic commands such as FTP_CONNECT, FTP_COMMAND, and FTP_DISCONNECT that can be strung together to create a complete file operation action. The FTP_COMMAND Function allows you to issue arbitrary FTP commands as long as the SAPFTP function, the Host, and the Destination server all support the command. Then you have the specialized functions such as FTP_R3_TO_SERVER, FTP_R3_TO_CLIENT, and FTP_CLIENT_TO_R3. This lets you take some data in memory and transfer it someplace else. This has the advantage of not having to write the data to the file system first and not to have to issue any FTP commands. However these functions are also limited to the scope described.
If you are already familiar with FTP in general, working with these function modules should not seem to difficult. The Connect, Command, Disconnect actions would seem somewhat self explanatory. So instead of looking at the entire program in detail let's focus on two things that may be unfamiliar. First the program starts off with an ABAP Kernel System call to AB_RFC_X_SCRAMBLE_STRING. Well we don't want to pass a potentially sensitive password openly. Therefore the FTP_CONNECT function module requires that the password be encrypted before it receives it. It is this System call that performs that one-way encryption. Now I checked a 620 SP42 system and in this example, SAP has replace the AB_RFC_X_SCRAMBLE_STRING with a function call to HTTP_SCRAMBLE. Unfortunately HTTP_SCRAMBLE doesn't even exist in my 46C system. The only other thing that I wanted to point out about these function calls is the exporting parameter on the FTP_CONNECT. It passes back a parameter called handle. This handle then becomes an importing parameter to all subsequent calls: FTP_COMMAND and FTP_CLOSE. This handle is the pointer to the instance of FTP that we started with the FTP_CONNECT. This assures that we get reconnected to the same FTP session with each command we issue.
FTP Development
I thought I would share a few of the things that can be built using this FTP functionality. First off I didn't want a bunch of ABAP programs directly working with the SAP FTP Function modules. As you can see there is already a difference in the examples for encrypting the password between 46C and 620. Therefore I thought it would be best to encapsulate all the FTP function in one custom ABAP OO Class. Not only did I get the opportunity to hid the inner SAP functionality and make it easy to switch out during upgrades, but I also get consistent error handling as well. I accept the User Name, Password, Host, and RFC Destination in during the Constructor of the class. I then store these values away in Protected Attributes. Each function module is then implemented as a Instance Method. The Password encryption functionality is then all tucked away nicely in the class. Also the calling program doesn't have to worry about keeping track of the FTP handle either since it is an instance attribute as well.
Next I got really carried away. I wanted a way to record entire FTP scripts that could be filled with values at runtime and ran as a step in a background job. My company used to have many interfaces that ran frequently sending files all over the place. We needed a mechanism to monitor and support these file moves. This was really the root of this tool, but it also gives you an idea of how powerful these functions can be.
Closing
I hope that anyone interested in FTP from ABAP will find this resource useful. If anyone has any other resources that should be included here, feel free to post them.
Thomas Jung is an Application Developer for Kimball Electronics Group (www.kegroup.com) and a huge fan of ABAP.
Comment on this weblog
Showing messages 1 through 7 of 7.
Titles Only
Main Topics
Oldest First
New to SAP/ABAP-4
2005-02-24 13:03:06 Thomas Godfrey Business Card [Reply]
I've been in IT for over 30 years as a mainframe contract programmer/analyst. Recently a company hired me for my legacy knowledge of there business to become a developer on SAP for these same systems.
My first task is to develop a generalized ftp application to send data to the mainframe and then on to financial institutions. I have created an ABAP/4 test program with literals for the dest/host etc. And it works fine. I need more detail/guidance in creating the Class/Method/Function you have described to make this parameter driven and callable by other programs. I know this is a lot to ask, any help in pointing me in the right direction would be greatly appreciated. When I mention class creation to the existing staff they all say "Oh, we don't use or know anything about that object oriented stuff, we just right programs."
Thanks,
Tom
New to SAP/ABAP-4
2005-02-24 13:13:33 Thomas Jung Business Card [Reply]
"we don't use or know anything about that object oriented stuff" That's something I might have expected to hear 4 years ago. That's kind of like saying that you only want to use half of the programming lanuage (the old half at that).
However it is true that you have to learn to walk before you run. There are some fundamentals to ABAP that are usefull to have down before you start in with ABAP OO. But I wouldn't let that hold you back for long.
I'm afraid that I wouldn't be able to teach you everything you would need to know to create a function module or a class in this posting. There was a nice weblog that was just posted the other day that had the steps to create your first simple class. I suggest you start there.
As far as my FTP class goes, I don't mind sending you the code for the class. My email address is already all over SDN (and spammers' lists) so just send me the address that you want the details sent to. My email is [email protected].
New to SAP/ABAP-4
2005-02-24 13:05:42 Thomas Godfrey Business Card [Reply]
I just read what I typed, I meant "write programs" not "right programs" ... duh
Good suggestions - now...
2004-11-24 09:15:27 Jacques Claassen Business Card [Reply]
...any chance you've used FTP via an HTTP proxy?
Any help using the HTTP* functions in the ZFTP function group will be greatly appreciated. Any one?
Thx
Good suggestions - now...
2004-11-24 09:59:11 Thomas Jung Business Card [Reply]
I'm afraid I haven't done either. However I have used the HTTP client functionality in the WebAS 620 (if_http_client) along with an HTTP proxy. I have an example of this in another weblog.
Pretty insightful
2004-11-15 19:27:26 Subramanian Venkateswaran Business Card [Reply]
Thanks for this weblog, and I can be pretty sure there are some(many) more weblogs in the waiting.
Regards,
Subramanian V.
I have been using a local include ...
2004-11-15 16:29:39 Swapan Sarkar Business Card [Reply]
On the other hand I have been using a local include of ZCL_FTP_BASE in my programs for some time. Here's the signature:
<quote>
*& Include ZHR9_FTP_CLASSES
*& Utility class ZCL_FTP_BASE having all the
functions to upload and download files from an
FTP server.
CLASS zcl_ftp_base DEFINITION.
PUBLIC SECTION.
Output file type
TYPES: BEGIN OF t_scratch,
data(1024) TYPE c,
END OF t_scratch,
t_str_tab TYPE STANDARD TABLE OF t_scratch.
CONSTANTS: co_crlf(2) TYPE x VALUE '0D0A'.
DATA: status TYPE c VALUE space.
METHODS: constructor IMPORTING im_user TYPE string im_pwd TYPE string
im_server TYPE string,
send_table_data IMPORTING im_file TYPE string
im_table TYPE t_str_tab,
get_table_data IMPORTING im_file TYPE string
EXPORTING ex_table TYPE t_str_tab,
send_string_data IMPORTING im_file TYPE string
im_string TYPE string,
get_string_data IMPORTING im_file TYPE string
EXPORTING ex_string TYPE string,
disconnect.
PRIVATE SECTION.
DATA: v_user(64) TYPE c,
v_pwd_clear(30) TYPE c,
v_pwd(64) TYPE c,
v_server(30) TYPE c,
v_filename TYPE rlgrap-filename,
v_handle TYPE i.
METHODS: pwd_scramble IMPORTING im_pwd TYPE c.
ENDCLASS. "ZCL_FTP_BASE DEFINITION
</quote>
Showing messages 1 through 7 of 7.
Pls. mark if this doc. is useful -
Download SPOOL to an internal table in Background
Hello,
I want to Download the Spool to an internal table, but in Background, the functions
RSPO_RETURN_SPOOLJOB
RSPO_RETURN_ABAP_SPOOLJOB
don't work.
Does anybody know another function or way to do it?
Thank you very much,
Maite.Hello,
Thanks for your help but I'm afraid it doesn't work...
In my system the function SO_SPOOL_READ doesn't exists... It might be obsolete.
The function RSPO_DOWNLOAD_SPOOLJOB doesn't work in Background... it sends a message xxx bytes transferred and cancels the job. and the file it is not created.
I don't know why these RSPO functions work in different way in background...
Maite. -
Upload Excel table to internal table in background
I am using fm ALSM_EXCEL_TO_INTERNAL_TABLE to upload Excel tables from the Application Server. The process works great in foreground mode.
My program requirement is to call an ABAP object from the SAP Job Scheduler (SM36/SM37). So when I run the ALSM_EXCEL_TO_INTERNAL_TABLE in a background job, the programs abends. In the job log, I get error ALSMEX037 Error during import of clipboard contents.
Has anyone seen this error? What causes this error? How can I get around this error in a background job?
<<text removed>>
Edited by: Matt on Mar 5, 2009 1:55 PM - do not offer rewardsHi,
From background its not possible for you to upload an excel file because the background jobs are run in different processors and they are not directly linked with the pc where the file is stored so the better way to read the excel file is to write another program and execute in frontecd which will read the excel file and store it on the application server and then from application server its easy to retrieve data into an internal table using open dataset and close dataset....
Regards
Siddarth -
How to pass an internal table to "submit job"
Dear Expert,
I use open_job & close_job to submit a background job.
A text file is to be uploaded from local drive.
Since we cant perform upload during the background,
I will have to upload the file from local drive in foreground, and then submit to the background job.
I tried to use Export [internal table] to memory and Import from the background job, it doesnt work.
How can I do this ??
Thank you.hi ,
you can do this using the open dataset...
i think it is the best one..
open dataset p_file for input in text mode encoding default .
loop at p_file.
output0(10) = p_file0(10).
output10(20) = p_file20(10).
output30(10). = p_file30(10).
output40(10). = p_file40(10).
endloop.
close p_file.
regards,
venkat. -
Download file from application server to internal table in background
hi all,
i want to download a file from appliaction server into my internal table but in background.
i had tryed CG3Z and CG3Y t-code but screen that is coming is asking for the parameters, and i want that screen should not appear and file should be saved in the predefined path by me.
if there any way to do so,
Points will be rewarded as per the Aswers.
thaks in advance.Hi Sudeep,
Use this code to get file data from application server.
REPORT ZE0232_BDC_APPLSERVER.
DATA: FILE_PATH TYPE STRING.
FILE_PATH = 'c:\bdc_mat.prn'.
DATA: BEGIN OF ITAB OCCURS 0,
END OF ITAB.
OPEN DATASET FILE_PATH FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC = 0.
DO.
READ DATASET FILE_PATH INTO ITAB.
IF ITAB-RESNO NE SPACE.
APPEND ITAB.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
CLOSE DATASET FILE_PATH.
LOOP AT ITAB.
WRITE:/ ITAB.
ENDLOOP.
FILE PATH IS application server path.
IF USEFULL REWARD -
Table for background job spool list ?
i know the table for spool request : TSP01
But how should i link it to background job name ?
i want the link between background job name and spool request.
TBTCPV is the view but it stores only one spool request.....rather than multiple spoolreq generated by background job..Hi,
Table TBTCP has the Spool Request field PLIST field as well as Jobname JOBNAME field in it. Youc an link them together.
Regards,
Anji -
Tables for background job details
hi
iam having a job name
i want to know the program name associated with this job or the events related to this job.
Iam not able to see this job in SM37/ SM36
any other way to find thisDId you check all available statuses and did you remove all not-required criteria from SM37 starting screen
Remember there are some jobs that purge logs and definitions of old jobs as well as job statistics.
(Jobs starting with SAP_REORG_JOBS)
To look for job statistics -> SM37 -> select job -> Goto -> Job Statistics
(So if you don't see the job in SM37...)
Regards,
Raymond -
Background job within another background job
Hello Experts,
I have a BDC program (for BW tcode OLI7BW) which executes by scheduling a number of background jobs. This report works fine when run manually. But doesn't work if it is scheduled as a background job through SM36. The status of the job is shown as finished, but the data is not uploaded.
Is it not possible to execute a background job within another background job?
If it's possible, what could be the possible cause of error?
Thanks In Advance
RadhikaHi Radhika,
If you are trying to upload data from a file on ur desktop to Internal table, then background job doesn't work. Always remember GUI means ur front end and all background jobs are run on application server and they dont run w.r.t ur desktop.
Kindly check it and get back to me incase of any queries.
Dont forget to reward points, if found useful.
Thanks and Regards,
Satyesh -
Update table form local file as background Job
Hi Expert,
I have a requirement to update a database table through Text file in a background. I am trying to do through OPEN Database to upload the file to Application server and then triggerind a event for background job. please provide method to update the table in background job.
Regards,
Kapil.hi,
if i have understood you can try this:
1) create a custom event with transaction SM62.
2) schedule the update job ( with the update program in its step ) trigging the event set in (1) .
3) execute the program that upload the local file from presentation server to application server . The last istruction of this program has to be the call ot the custom event using BP_event raise fn module in the uplaoad is ok..
4) if the event has been raised, the background job has been executed.
Regards, luigi. -
Table that stores Job Log details
Dear Experts.....!!
I have an issue, for which I need to access the Start Date, Start Time and the End Time for a Particular Back-ground Job.
I'm not able to figure-out the table that contains these details.
The Input that I can provide is the Job Name and I need the recent Start Date, Start Time and the End Time for the given job.
Please help me in this regard.
Thank you all in advance.
Best regards,
NaveenHi Naveen,
Please check the foloowing tables --
TBTCO - Job Status Overview Table
TBTCD - Job Log Directory
For more information you can check the followings --
TBTCA Subsequent relationship in batch job sche
TBTCB Preceding relationship in batch job sched
TBTCCNTXT Information for Assignment of Jobs to Com
TBTCCTXTT Description of Reference Types for Backgr
TBTCCTXTTP Check Table: Valid Job Reference Types
TBTCI Usage counter for the job's internal repo
TBTCJSTEP Background Job Step Overview
TBTCO Job Status Overview Table
TBTCP Background Job Step Overview
TBTCR Batch scheduler execution time
TBTCS Background Processing: Time Schedule Table
Regards
Pinaki -
Download internal table to XSLX on SAP application server
I was struggling with this feature for a longtime and finally found some solution and so thought of listing it:
Here is what I did to download an internal table to xslx format (works for xls aso) :
I found this excellent link that allowed me to download an XSLX file on to local directory and then I added a little more to download to app server.
http://abapblog.com/articles/tricks/33-create-xlsx-mhtml-file-from-internal-table-in-background
<
Per this link. once the bin file is prepared, pass it to
CALL FUNCTION 'HR_CA_DOWNLOAD_TO_APPSERVER' EXPORTING filename = p_file filesize = g_size IMPORTING bytes_transfered = len TABLES data_tab = gt_bintab EXCEPTIONS invalid_filesize = 1 no_authority = 2 dataset_open_error = 3 OTHERS = 4.
This works for xslx as well as xlsI guess you want to transfer XML document type ref to IF_IXML_DOCUMENT (which is instantiated with this method and stored in attribute M_DOCUMENT ) to a file on application server. Is that right?
If so please refer below program you should get the idea
DATA: gr_ixml TYPE REF TO if_ixml,
gr_ixml_doc TYPE REF TO if_ixml_document.
gr_ixml = cl_ixml=>create( ).
"here you have the same kind of XML document
"as the one created with method CREATE_WITH_DATA
gr_ixml_doc = gr_ixml->create_document( ).
DATA gr_ixml_element TYPE REF TO if_ixml_element.
CALL METHOD gr_ixml_doc->create_element
EXPORTING
name = 'JOBS'
RECEIVING
rval = gr_ixml_element.
CALL METHOD gr_ixml_doc->append_child
EXPORTING
new_child = gr_ixml_element.
CALL METHOD gr_ixml_element->set_attribute
EXPORTING
name = 'OBJID'
value = '566677890'.
"serialization
DATA g_encoding_type TYPE string.
DATA g_stream_factory TYPE REF TO if_ixml_stream_factory.
DATA gr_encoding TYPE REF TO if_ixml_encoding.
g_stream_factory = gr_ixml->create_stream_factory( ).
gr_encoding = gr_ixml->create_encoding( byte_order = 0
character_set = 'UTF-8' ).
DATA b_xml TYPE xstring.
DATA gr_ostream TYPE REF TO if_ixml_ostream.
gr_ostream = g_stream_factory->create_ostream_xstring( b_xml ).
CALL METHOD gr_ostream->set_encoding
EXPORTING
encoding = gr_encoding.
CALL METHOD gr_ixml_doc->render
EXPORTING
ostream = gr_ostream
recursive = 'X'.
DATA g_resize TYPE i.
g_resize = gr_ostream->get_num_written_raw( ).
data ex_tab type table of x255.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = b_xml
tables
binary_tab = ex_tab.
"now open file on application server
OPEN DATASET dset FOR OUTPUT IN BINARY MODE.
"and transfer ex_tab to dset
Regards
Marcin -
Upload XML file from Application Server to Internal Table
Hi Experts,
i have xml file in application server and i want to convert to internal table .
i have tried this link http://wiki.sdn.sap.com/wiki/display/ABAP/UploadXMLfiletointernal+table.
Here the file is loaded from local(presentation Server) ..
i want to know how to select file from application layer ..and schedule in background..
i also tried FM '/SAPDMC/LSM_F4_SERVER_FILE' but this need front end selection of file from application server..
i need to select a xml file from application server and convert into internal table in background.. help me on this..Have a look on
Re: How to convert XML data to different ABAP internal table
Thanks
Ravin -
Logic or FM to fetch Background Jobs
Hi,
There is a reqmt to fetch the background jobs from tables TBTCO.
Here inthe selection screen planned start date to be given and program need to fetch the jobs which were run till previous day data from the table .
Background job logs however are cleaned-up every week.
How to achieve this, any pointer pls.
Thanks
Moderator Message: please work yourself first on your requirement.
Edited by: Thomas Zloch on Dec 13, 2010 12:29 PMhi,
after entering output type and giving all the necessary parameters before saving put /h and press enter and save now
wait here......
in debugging screen select settings tab and check update debugging check box and save and press F8 now the control will stop at the break point.
i think this is clear.
reward points if useful.
thanks,
anupama.
Maybe you are looking for
-
Unable to create Disc Image from DVD
I get the following error when trying to make a copy of a family wedding DVD. I'm using Disc Utility and creating the image as a DVD/CD master (.cdr) file. It gets to about 3/4 of the way and then gives the following error. The internal drive is a PI
-
SAP Status to show Assigned Document
Good Morning DMS users, I am new to this functionality (DMS) and would like to incorporate it into SAP PM to have documents assigned to : A) Functional Locations B) Equipments C) Work Orders My Questions are as follows: A) If a document is assigned t
-
C# VisualWebpart get Images from a specific Image Library.
Hello, I'm working on a VisualWebpart Project in VS2013. Are there any possibilities, where I can get the Images from a Image Library? Like this: //pseudocodeSPLibrary imagesLib = new SPLibrary("mySite\Library") var imageList = imagesLib.GetContent("
-
Keine Kreationen-- Photoshop Album 2.0
Hallo, ich habe heute das Programm von meiner Schwester bekommen und installiert,aber ich kann nichts damit machen. Keine Kreationen,Alben,Grußkarten....Es heißt immer ich muß mir was runterladen....aber wo? Vielleicht kann mir jemand helfen? Liebe G
-
hi to all, In CS03 t-code, I m providing Material no., Plant, Bom Usage and Alternative Bom, then pressing enter , another screen is displayed, in which all the bom component are dislayed. Now my problem is that all this component are coming from STP