Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Transfer table contents issues in email sent and attachment opened.

Former Member
0 Kudos

hello,

i am sending email(from program) with attachment (sapshortcut of a ztransaction) to external email address.

i am exporting internal table with data to memory id so that when user open that attachment(sapshortcut),

i'll be able to import that internal table and then allow user to process that data.

I am using statement:

free memory id 'it'.

Export itab to memory id 'it'.

And i email, when attachment(sapshortcut) is opened i am using:

import itab from memory id 'it'.

But this use case seems to be not working.Import statement sets SY-SUBRC = 4.and itab is not imported.

What else is the alternative option.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
I understand that FM SWN_CREATE_SHORTCUT has a parameter
I_PARAMETERTYPETEXT255

for sending data (for the called transaction while opening sapshortcut,sent as an attachment), but how am i gonna fill fieldname,dynpro name,fieldvalue.

Basically i am calling a BDC, when sap shortcut (sent as attachment) is opened in an email.

BDC has a structure BDCDATA (which has 5 fields).

How am i going to populate those 5 field name and their field values, also dynpro name and dynpro values.

29 REPLIES 29

Former Member
0 Kudos

Hi Abhishek,

TRY USING

EXPORT p1 = itab1 to memory id 'M1'.

IMPORT p1 = itab1 from memory id 'M1'.

in case of tables, only the table body is exported/imported and not the header line

Thanks & Regards,

Seshadri

0 Kudos

i only want to export table body ..NOT the header line.

I have created itab without header line.

Command you have written (not working too ) are same as i have posted in questions.

0 Kudos

Hi Abhishek,

EXPORT s_qmdat_r FROM s_qmdat_r[] TO MEMORY ID 'Z3DAT1'.

IMPORT s_qmdat_r FROM MEMORY ID 'Z3DAT1'.

   IF s_qmdat_r[] IS NOT INITIAL.

   ENDIF.

Check the below points :

  • Whether both programs that the S_QMDAT_R has the same structure as the other working ones.
  • Whether  internal table had data in it at the point of EXPORT
  • Check SY-SUBRC 0 for both statements

Thanks & Regards,

Seshadri.

.

0 Kudos

These all are the same thing seshari.

Whether i use:

EXPORT ITAB FROM ITAB[] to memory id 'mem'.

or

EXPORT ITAB  to memory id 'mem'.

While importing ITAB is declared of same structure when exporting.

Please read Nick's comments. This may be the reason of failure in import.

Former Member
0 Kudos

Hi Abhishek,

I don't think memory IDs persist across the sort of process you describe.

If I read the ABAP help it says "A data cluster in the ABAP memory is available to all programs within a call sequence".  And defines call sequence as "A call sequence is the set of programs whose internal sessions are loaded jointly in a main session by a sequence of calls.....".

If you are generating an e-mail from SAP then the receiving user opening this and navigating to the link will not be operating within the same call sequence.

Regards,

Nick

0 Kudos

If you are generating an e-mail from SAP then the receiving user opening this and navigating to the link will not be operating within the same call sequence.

Thanks Nick,

I was suspecting this may be the reason , i am not able to import my internal table in other call sequence(navigating back to sap from EMail).

What solution you see for this ,please guide me.

0 Kudos

Hi Abhishek,

Let me check I understand the requirement.  You have a program that generates a table of data and sends an email, the email contains a link to a Z-transaction that reads this table of data and presumably presents it to the user.

Does the Z-transaction need to be given the table of data?  Could it not construct the table in the same way the email program does?

Regards,

Nick

0 Kudos

Does the Z-transaction need to be given the table of data?

Yes. Ztransaction reads that table(exported before sending email), and presents to the user.

 Could it not construct the table in the same way the email program does?

No, this data extract (before sending email) , can NOT be fetched again using the same way. because then the time consumption in calculation of that data will be huge(many select's ,read statements) and so will be useless.

I need to find some way to import that data.

0 Kudos

Why not save internal table to database "Z-table" ?

Just be sure to handle old data properly (according to your process) so you do not end up with table getting bigger and bigger without some maintenance.

-- Tomas --

0 Kudos

This Email sending (data fetch from lots of table...basically deals with failed idocs) will be scheduled in batch ,may be hourly basis, so it will not be possible to save everytime entire failed idoc data in DB and fetch the same while opening attchment.

0 Kudos

So it might look like this:

hour 1:

select data to itab_#1 => send mail with shortcut #1

hour 2:

select data to itab_#2 => send mail with shortcut #2

etc..

And whenever user opens shortcut #x you want show him itab_#x data ?

Or all shortcuts pointing always to last recent itab_#x data ?

-- Tomas --

0 Kudos

Tomas Buryanek wrote:

hour 1:

select data to itab_#1 => send mail with shortcut #1

hour 2:

select data to itab_#2 => send mail with shortcut #2

etc..

And whenever user opens shortcut #x you want show him itab_#x data ?

Tomas,Think like this,(This is a rough scenario.)

If somehow i'll be able create a dynamic memory id to export itab data.

Export ITAB to memory id dynmemory."dynmemory is a variable which container dynamic memory id.

"every hour we can concatenate some number or time stamp with the memory id and then export.

Send This memory id with sap shortcut (as attachment). FM SWN_CREATE_SHORTCUT has a parameter for sending some field values.

When importing,first program will read that parameter in order to fetch memory id , then it will import data from that memory id only.(not from the recent export).

This is just a rough sketch.Firstly, i am not able to use simple EXPORT/IMPORT statements.Then creation of dynamic memory id's will be an issue. and so on.I am looking for some kind of export import itab data(which should work, when abap sessions are not in call sequence as well).

Let me know if you are still far from the point.

0 Kudos

That ITAB will have dynamic structure? If not, then I do not understand why you do not want save these data to database Ztable?

-- Tomas --

0 Kudos

Tomas Buryanek wrote:

That ITAB will have dynamic structure? If not, then I do not understand why you do not want save these data to database Ztable?

That ITAB is not of dynamic structure.

The reason why i am not saving this data in database table,is because this program will probably run on hourly basis and fetches huge records (from many select statements),each days there will be crores of entries that will be saved in DB, and of no use. Because one user opens attachment (sent with email), process those records. then we are done. We don't need that data anymore.

Don't you think this will be unnecessary to save all this data in DB (may be duplicate data as well..if user processed few records, and then again another hour prog will run and fetches same..unprocessed data).

secondly, Daily basis administrator have to clean that DB table (it may overflow, due to huge list of records getting saved on hourly basis).

0 Kudos

What is "huge records"? How many lines of itab each hour (approximately)?

You can delete unwanted entries after user process them. You can also delete entries older than lets say week (if they are obsolete). Or maybe re-think about this process...

-- Tomas --

Former Member
0 Kudos
I understand that FM SWN_CREATE_SHORTCUT has a parameter
I_PARAMETERTYPETEXT255

for sending data (for the called transaction while opening sapshortcut,sent as an attachment), but how am i gonna fill fieldname,dynpro name,fieldvalue.

Basically i am calling a BDC, when sap shortcut (sent as attachment) is opened in an email.

BDC has a structure BDCDATA (which has 5 fields).

How am i going to populate those 5 field name and their field values, also dynpro name and dynpro values.

0 Kudos

Just create or use a file of same structure than INDX, don't export to memory but to this database with EXPORT TO DATABASE statement, and give the key/id of the export to the transaction parameter shortcut, you can concatenate other (short) information to the parameter, the called transaction if required, this transaction will execute the IMPORT FROM DATABASE statement.

Sample Caller


EXPORT

     tcode FROM lv_tcode
     bdcdara FROM lt_bdcdata
    TO DATABASE zindx(bc) ID lv_id.

Sample in called


IMPORT

     tcode TO lv_tcode
     bdcdata TO lt_bdcdata

     FROM DATABASE zindx(bc) ID lv_id.

CALL TRANSACTION lv_tcode

     USING lt_bdcdata.

Regards,

Raymond

0 Kudos

Raymond,

Thanks for your suggestion.

I see this (what you have mentioned), only way through this.

I have read the documentation of 'EXPORT TO DATABASE' Statement but didn't got much.

Please clarify some of the points.


Raymond Giuseppi wrote:

Just create or use a file of same structure than INDX,

Do i need to create a internal table of same structure as of transparent table INDX? If yes, then i may need to transfer ITAB (data table) contents to GT_INDX (internal table INDX structure) table?

Do i need to concatenate all fields (of a row) in a single column and then transfer to GT_INDX-CLUSTD ?


give the key/id of the export to the transaction parameter shortcut,

How i am going to do this. Didn't understood what does that mean.

Much better,Lets say i have a internal table with 1000 records GT_MAKT (type MAKT- all fields), and i want to export this to DATABASE using 'EXPORT TO DATABASE STATEMENT'.Can you elaborate , what are the steps  do i need to follow to successfully export/import this.

What about its key field.

0 Kudos

'EXPORT TO DATABASE'  command doesn't work to Background job.

Any solutions?

0 Kudos

No, this statement allows you to export most types of data, in my example I exported the transaction code and the bdcdata internam table. The statement will convert your whole batch of field, itab and structures to the cluster table, don't care on it.

  • Just copy INDX into your namespace (e.g. ZINDX)
  • To identif a record, you have a type (in my sample I use constants 'BC') and a free key ID (type indx_srtfd, 22 characters) that you will define yourself (e.g. user + date or a counter or any key of less than this length)

Regards,

Raymond

0 Kudos

dear raymond,

I guess i am close to it.


To identify a record, you have a type (in my sample I use constants 'BC') and a free key ID (type indx_srtfd, 22 characters) that you will define yourself (e.g. user + date or a counter or any key of less than this length)

The problem which i can think of wil be to identify record.

See,This program will run in batch on hourly basis.So, i will concatenate ID With sy-datum,sy-uzeit(time and date stamp). and pass this to sap shortcut as parameter.

When user clicks on that shortcut (email attachment),is there is some way to read these parameters, so that i'll get the key which i have exported and then  based on that free key i'll import from database cluster.


Below Screen, i am passing Parameters(Free key concatenated with time and date) in sapshortcut and  SHORTCUT_STRING is generated by this function module(which is responsible for calling transactions ).

I need some way to retrace back, to get parameters i have passed. thi sway i'll get the hey and so data which i have exported.

0 Kudos

No idea how to pass parameter in such shortcut (fear that the parameter is only intended for connection string), could you consider giving only user as ID value, and always reading last execution or provide use a selection of available exported data ?

0 Kudos

could you consider giving only user as ID value, and always reading last execution or provide use a selection of available exported data ?

If i do this(giving only user id as a key ID), then when i have 10 emails(each with sap shortcut as attachment), how would i'll be able to differentiate between them.

I can read (IMPORT) last execution.Because:

Hour1:

exported 50 IDOcs that user need to process.->send email with timestamp and date as key.

Hour 2:

Exported 50 different idocs that need to be processed ->email sent with diff time and date as key.

Suppose now user reads and opens 1st(hour1)email, then last execution(latest export) will read hour 2 idoc details.(which in turn i need to read hour 1 detail).

So, if i am seeing this right, send time and dat stamp as parameter and when opened attachment(sap shortcut), read time and date stamp(issue i am currently having) and then according to that key read cluster from database.

0 Kudos

To parameter you can put field names and their values of transaction you want start.

Example command:

/n*se38 RS38M-PROGRAMM=ZPROGRAM

(parameter for SWN_CREATE_SHORTCUT would be: "RS38M-PROGRAMM=ZPROGRAM").

I guess you are starting Ztransaction so you can create parameter (maybe hidden) on selection screen where you will put your unique ID.

-- Tomas --

0 Kudos

I guess you are starting Ztransaction so you can create parameter (maybe hidden) on selection screen where you will put your unique ID.

yes, this is what i earlier thought. but it seems this will not work either.

Reason:

This parameter will be filled like this:

fieldname 'indexkey'

fieldvalue 'idoc20150112173141' <- key concatenated with time and date (to make it unique).

Problems:

Firstly, if i make a selection screen, with 1 field-key(no display), and pass key to parameter in sapshortcut,

then (i need to add something that after key is inserted in that selection screen field and then automatically press F8.)

How can i do this?

Secondly, i thought of making module pool(with 1 field on screen),key field is populated on opening attachment(sap shortcut) , i just need to press ENTER Automatically.

That all, then i am done.Please guide how to do that.

0 Kudos

SAP Shortcut is simle textfile - if you open it and add * in front of transaction (in line "Command="), it will skip first screen (like you would press F8).

I do not know if it is possible / how to pass it to SWN_CREATE_SHORTCUT. But I guss it works like simple concatenating FM parameters so you can pass * somewhere there

-- Tomas --

0 Kudos

using * and shortcut parameters simultaneously is not working.

I am able to use either *( selection screen skipped) or parameters in sapshortcut.

0 Kudos

For me it is working. But I am not using that FM.

Check example here:

-- Tomas --

0 Kudos

Thanks Tomas, for your continuous help.

You saved my night.(i might have spent whole night...thinking to fix this).

DYNP_OKCODE=ONLI; "this was missing.