Application Development and Automation 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: 
Read only

Saving text from text editor into ztable

Former Member
0 Likes
4,878

Hi experts ;

I have a custom dialog program for inputing and saving data to z-tables.

I want to save data(texts with no limit) into z-table from text editor object.I created text editor container but i can't save texts.

I know it is possible with cluster table.But i don't know how.

Do you have a simple code or program ?

Thanks all..

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,609

First create a database table (if you don't already have one) by copying table INDX into your namespace.

You will then read/update/insert in this table the whole text internal table via statements EXPORT and IMPORT from database.

Regards,

Raymond

21 REPLIES 21
Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,610

First create a database table (if you don't already have one) by copying table INDX into your namespace.

You will then read/update/insert in this table the whole text internal table via statements EXPORT and IMPORT from database.

Regards,

Raymond

Read only

0 Likes
3,609

Hi Raymond ;

So can i apply a relation with a number which i input at selection screen?

Because, i have to see texts with my custom number object ,at my zreport

Thanks.

Read only

0 Likes
3,609

Yes, you can

Sample:

Created table

Abap code

  logkey+0(12) = sy-uname.

  zfsh_indx-aedat = sy-datum.

  zfsh_indx-usera = sy-uname.

  zfsh_indx-pgmid = sy-repid.

  EXPORT worklist[] TO DATABASE zfsh_indx(wl) ID logkey.

  COMMIT WORK.

Where 'W1' identifies a subset of the table and logkey is the key that identifies the record (use a structure). You can add some field to the database table definition (here information on who did update the table) to help querying the table, and export some fields and internal table in the cluster part.

Regards,

Raymond

Read only

0 Likes
3,609

Thanks for your very helpful sample.

I will try that.

I have a ID number which is working with my custom number object, and which is indentifies my worklist number. So i want to write comments under this input.

And i will write a report, which contains this inputs and texts..

What about SAVE_TEXT FM ? What do you think about this ?

Thanks a lot again, for your spending time .

Regards.

Read only

0 Likes
3,609

Saving the long text (but only the text) via the SapScript editor is easier, use FM READ_TEXT, SAVE_TEXT First create an object via transaction SE75.

Many samples in scn wiki.

Regards,

Raymond

Read only

0 Likes
3,609

  logkey+0(12) = sy-uname.

  zfsh_indx-aedat = sy-datum.

  zfsh_indx-usera = sy-uname.

  zfsh_indx-pgmid = sy-repid.

  EXPORT worklist[] TO DATABASE zfsh_indx(wl) ID logkey.

  COMMIT WORK.

In this code, how can we save text which is in the text editor ?

Read only

0 Likes
3,609

This is only a sample copied from my sandbox, adapt it to your case, replacing the value of logkey with a key suitable to your data and worklist[] with your text lines (eg. internal table get by method GET_TEXT_AS_R3TABLE)

Regards,

Raymond

Read only

0 Likes
3,609

Of course I know,too that's a sample.

i was meaning saving method of text editor contents.

so as i can see, "GET_TEXT_AS_R3TABLE".

Thanks.

Read only

Private_Member_49934
Product and Topic Expert
Product and Topic Expert
0 Likes
3,609

It is not recomended that you save your long text ( from editor object ) to a database table. Use the interface provided by SAP to save the long text. This is what all the standar application does ( list sales item long text, etc etc )

I suggest you go for the following

1) create a z- text object and text-id using tcode se75. ( From sap help )

2) concatenate the key field of your z-table and use it for object name .

3) Call the FM the function module SAVE_TEXT

     

  WA_THEAD-MANDT    = T_TEXTS-MANDT.

      WA_THEAD-TDOBJECT = z-object you created.

      WA_THEAD-TDID     = z-id you created

      WA_THEAD-TDNAME   = concatenation of key field

      WA_THEAD-TDSPRAS  = your language.

      ta_lines from you text object

        CALL FUNCTION 'SAVE_TEXT'
        EXPORTING
          HEADER          = WA_THEAD
          SAVEMODE_DIRECT = 'X'
        TABLES
          LINES           = TA_LINES
        EXCEPTIONS
          ID              = 1
          LANGUAGE        = 2
          NAME            = 3
          OBJECT          = 4
          OTHERS          = 5.

3) commit work.

4) while retriving the data use READ_TEXT.

Read only

0 Likes
3,609

Hi Kumar ;

Thanks for your answer. But I have to develope an interface like "PFCG" transaction's "Description" tab (with text editor).

Can i apply your method for this situation ?

Thanks a lot.

Regards.

Read only

0 Likes
3,609

Yes absolutely.

Just from description, I think there are text object and id in se75 ( /VIRSA/RDS ) for role description. This method is used for all long text ( You can check yourself for text objects like VBBK,VBBP,VBKA, AUFK  in the table STXH which is the header table for long text )

Read only

0 Likes
3,609

http://help.sap.com/saphelp_nw70/helpdata/en/d6/0db8c8494511d182b70000e829fbfe/content.htmI think Kumar is absolutely correct, there might be a problem in saving data directly to the database table.

There are few steps Kumar has already suggested and also I tried those, working fine.

No issues in that, coming to your last point - Like a PFCG t-Code

If you are talking about the above long text, then its very much possible with the solution kumar has provided.

Just need to read the text back by READ_TEXT function module with proper Object-Name and Object-ID with which it got created.

Below Sample code: Might help

  wa_thead-mandt    = sy-mandt.

wa_thead-tdobject = 'ZRDX'.
wa_thead-tdid     = 'Z1'.
wa_thead-tdname   = 'Z1771'.
wa_thead-tdspras  = sy-langu.

wa_lines-tdline = 'First'.
APPEND wa_lines TO ta_lines.
wa_lines-tdline = 'Second'.
APPEND wa_lines TO ta_lines.
wa_lines-tdline = 'Third'.
APPEND wa_lines TO ta_lines.
wa_lines-tdline = 'Fourth'.
APPEND wa_lines TO ta_lines.
wa_lines-tdline = 'Fifth'.
APPEND wa_lines TO ta_lines.

CALL FUNCTION 'SAVE_TEXT'
  EXPORTING
    header          = wa_thead
    savemode_direct = 'X'
  TABLES
    lines           = ta_lines
  EXCEPTIONS
    id              = 1
    language        = 2
    name            = 3
    object          = 4
    OTHERS          = 5.


IF sy-subrc EQ 0.
  WRITE : '1.Success'.
ELSE.
  WRITE : '1.No Success'.
ENDIF.


REFRESH: ta_lines.

CALL FUNCTION 'READ_TEXT'
  EXPORTING
    client                  = sy-mandt
    id                      = 'Z1'
    language                = sy-langu
    name                    = 'Z1771'
    object                  = 'ZRDX'
  TABLES
    lines                   = ta_lines
  EXCEPTIONS
    id                      = 1
    language                = 2
    name                    = 3
    not_found               = 4
    object                  = 5
    reference_check         = 6
    wrong_access_to_archive = 7
    OTHERS                  = 8.


IF sy-subrc EQ 0.
  WRITE : '2.Success'.
ELSE.
  WRITE : '2.No Success'.
ENDIF.

Output was : 1. Success 2. Success

Nothing new than Kumar suggested ............ just had some sample code on PFCG kind of layout and SAVE_TEXT /.//....

Read only

0 Likes
3,609

Thank you Ravindra ;

But i have a ID number which is working with my custom number object, and which is indentifies my worklist number at the input screen. And i will use this saved text at my zreport.

How can i do that ?

Thanks a lot.

Regards.

Read only

0 Likes
3,609

Hello Cevat,

I think you are mixing the two different approaches here,


1. One- With Z-Table directly saving data, using IMPORT / EXPORT and INDX structure.

****** Which Raymond has suggested

2. Second – Kumar and me are trying to explain, which exactly don’t need direct database saving. Here you need to create a Custom Text Object in SE75 and use the READ_TEXT and SAVE_TEXT FMs.

Okay,  I will go with the Approach suggested by Kumar and Me with the help of your question only.

But i have a ID number which is working with my custom number object, and which is indentifies my worklist number at the input screen. And i will use this saved text at my zreport.

How can i do that ?

As far as your custom number object concerned and is identifying your worklist number in a selection screen and its UNIQUE, you wont have to bother about the SAVE_TEXT. As passing the correct and unique Object-ID and Object-Name will work out for SAVE_TEXT.

I really do not see any hurdle in saving the text in Text-Object, irrespective of where you are writing your business logic to save it, whether in report or in any given option.

I do not understand what exactly is bothering you? Can you please be little bit brief about what exactly you want to acheive.

I think you are very close to the solution, only need to chose your way of doing it.

Read only

0 Likes
3,609

Hi Ravindra ;

At first thanks a lot your helpful answers.

I'm designing a work list follow-up architecture.

First of all, i created a dialog screen for works main data (date,user ,work code,short text .. etc.) input.

You can think, i am giving an unique work number manualy at input screen.

At same screen, i want to save comments of work which in the text editor contents.

After input main datas, i'll write a z-report and i will list all of works.

So, i will want to see each work details which i saved before(at text editor), in this z-report.

Regards.

Read only

0 Likes
3,609

Dear Cevat,

I think the module screen (Dialogue Screen) is a different, and will be used for only data entry of your Work list data. And then there will be a Z-Report which will take care of the data reteival and listing purpose. Please let me know if we are on same page.

If we are on the same page then I would be helpful.

1. Create a Module pool Screen (Dialogue Screen), write a business logic to save the data in to cluster table using SAVE_TEXT function module in a PAI, keep a track of created/entered WORKLIST Number in a Z-Table somewhere. Refer to WIKI or the above code snippet I shared with you.

Z-Table Addition : This Z-Table will be refered for the reporting purpose. Keep all the related data for saving Long text in this Z-Table, and make sure all the data is saved properly which would suffice to make a READ_TEXT function module.

2. After saving of Long Text by SAVE_TEXT and saving all the related data to the Z-Table, you can now create a Custom Report with all the necessary Selection Screen.

3. Related data will be read from the Z-Table depending on the Selection Criterion, and based on the saved WORK Number, i.e. Object-Name, Object-ID, you can read the Long Text by READ_TEXT function module in the report itself.

I think this might serves the purpose.

Please let me know if we are not in a sync and your idea is different than what I am thinking of.

Thanks and Regards,

Ravindra Sonar. 

Read only

0 Likes
3,609

Do you mean you want to see the complete long text in ALV? what if your long text is say characters?

Alv won't work like excel word wrap.

What I suggest

1) display say first 50 characters on alv.

2) Ondouble clicking a particluar line ( or you may add your own button on alv tool bar ) open the text editor as popup and display the complete line.

As sugeest you will need to use read_text to read the long text. Rest logic you must be knowing.

Read only

0 Likes
3,609

Hi Ravindra ;

I'm saving my worklist main data in a z-table.

Did you mean ,creating another cluster z-table for text, which contains my worklist number and key field ? Because i have to apply a relation with WORLIST NUMBER and TEXTID...

Thanks a lot .

Regards.

Read only

0 Likes
3,609

Hi Kumar ;

It's not important. I think like you about double click and detail popup.

My problem , i couldn't apply a relation with my custom WORKLIST number and long TEXTID.

Thank you.

Regards.

Read only

0 Likes
3,609

Dear Cevat,

I'm saving my worklist main data in a z-table.

In this table only why can't you save your Object-ID and Object-Number? So when you want to read it you can read related information and can fetch data from READ_TEXT?

Also there Kumar has suggested a Popup on double clicking or on the button in status. That is also a good idea, you can have a custom screen and by calling screen and putting custom Controller to show the data in a text input as in input disabled mode .....

There could be various option available to show the data .....

------------------------------------------------------------------------------------------------------------------------

Did you mean ,creating another cluster z-table for text, which contains my worklist number and key field ? Because i have to apply a relation with WORLIST NUMBER and TEXTID...

I did not mean to add new cluster table at all, sorry if I made you confused. If you already have one

Z-Table then why don't you use that only to store the relation between the WorkList No. and TEXTID?

regards,

Ravindra Sonar

Read only

0 Likes
3,609

Text id has three main componenet apart from laguage

ID , OBJECT, NAME.

You create custom OBJECT AND ID in se 75 and use it throughout any application using your z-table.

Name = concatenation of mandt and key fields ( in your case mandt and worklist ).

don't create any field for long text in you ztable as object and id will be same for each and every row.

Now when you want to save the text for world list say ( 123456 ) put object name as say (300123456 ) assuming client 300.

while reading long text using the same