10-27-2020 6:32 PM
Hi Experts,
I have a requirement to use read_text FM but using select-options for name field. The issue is that, I'm not using any table like BSEG, MARA, etc. the requirement is to be able to put any document in the field without referencing the field to any table (ex: select-options docnam for table-field). I tried using:
select-options docnam for thead-tdname.
but when I clicked on selection screen Multiple selection button of the select-options for thead-tdname, it gave a dump: invalid_dynprofield.
All examples I checked used a table for the select-options. Any inputs is much appreciated.
rich.heilman - hope you can provide inputs.
Thank you,
Jeffrey
10-28-2020 8:53 AM
Could you try something like
DATA: thead TYPE thead,
text_headers TYPE TABLE OF thead,
text_table TYPE text_lh.
PARAMETERS: object TYPE thead-tdobject.
SELECT-OPTIONS name FOR thead-tdname.
PARAMETERS: id TYPE thead-tdid,
spras TYPE thead-tdspras DEFAULT sy-langu.
START-OF-SELECTION.
SELECT * INTO CORRESPONDING FIELDS OF TABLE text_headers
FROM stxh
WHERE tdobject EQ object
AND tdname IN name
AND tdid EQ id
AND tdspras EQ spras.
CHECK sy-subrc EQ 0.
CALL FUNCTION 'READ_TEXT_TABLE'
IMPORTING
text_table = text_table
TABLES
text_headers = text_headers
EXCEPTIONS
wrong_access_to_archive = 1
OTHERS = 2.
CHECK sy-subrc EQ 0.<br>
Or paste the code you wrote that triggered the INVALID_DYNPROFIELD.
NB: You will get some problem if some of the fields have a conversion-exit and/or a different length, e.g. two fields with ALPHA conversion exit but different length will cause problems due to wrong number or trailing zeroes.
10-27-2020 6:56 PM
jeff.broodwar
Hi Jeffrey,
I'm currently offline and cannot quickly check in a SAP-system but check out FMs READ_MULTIPLE_TEXTS and READ_TEXT_TABLE which allow wild-card searches for long texts. There's more information in OSS-Note 2261311 - Function module for reading multiple SAPscript texts.
Hope this helps!
Cheers
Bärbel
10-27-2020 7:20 PM
Thanks Barbel, although I would want to use READ_TEXT since I think it's possilbe. The main issue would be what select option declaration can I use to associate it with thead-tdname. Normally, programs use MARA like p_matnr, this time there's no specific table, it's as if the program is going to be used by different modules where they can input any document (material, accounting, etc..)
My functional mentioned, we can skip the HIGH value of the select options, they just need to be able to select the multiple button (select-options range) and paste there say 10 documents (can be material, accounting, etc.) then call read text. there are other mandatory fields in the screen such as OBJECT, ID. The thead-tdname (name) makes it challenging.
I can use BSEG then advise them that the high value will not work since I'll not use select statement to verify the documents, but using bseg-belnr, when I click on multiple button, there will be no dumps, I can paste say 10 documents then click on execute. I dont need to verify each document from bseg inside the code, just get the 10 documents inside the select-options variable range and process it in the READ_TEXT FM.. but then I think it's a bad design...
Is there a select-options data type I can use to allow me to paste multiple range of data then use it in read_text FM? If there's a way other than select-options to paste document numbers other than declaring 10 text fields in the screen then it's also a possible approach. as of now I'm stuck with select-options...
10-27-2020 8:00 PM
Hi Jeffrey,
the READ_TEXT FM always only reads the texts for one "entity", be it a financial document, some long material text or whatever. And you also need to specify values for the other input parameters like TDID, TDOBJECT and SPRAS. There's no way to directly use a select-option to retrieve multiple texts via one call of READ_TEXT. This is where the FMs I mentioned come in. You can do a pre-selection from table STXH (where the text headers are stored) and look for whatever keys you want and then use the result you get from that to build the input parameters for FM READ_TEXT_TABLE (as explained in the OSS-Note). IIRC, there are also example programs available which you'll find when you do a where-used in SE37 for the two FMs. These might give you some ideas of how to tackle this. If this can wait until tomorrow, I can also look for some ABAP-code of how I implemented the FMs to retrieve generic long texts.
Cheers
Bärbel
10-28-2020 4:04 AM
Thanks for your time barbel, yes we cannot use read text by just one call, I'm planning to loop through the select-options and pass each value inside readtext one at a time.
Regarding the FMs mentioned, None of them exist in our system..were using 740..
can you please take a look as well my question related to this, I'm looking for alternative way to declare select-options without table reference such as mara,bseg,etc. I tried thead-tdname, ztable but when I click on multiple button in selection screen of the select-options field it gives a dump.
https://answers.sap.com/questions/13175157/selection-screen-field-for-multiple-entries-withou.html
Thank you,
Jeffrey
10-28-2020 5:13 AM
jeff.broodwar
Hi Jeff,
can you ask your basis team to have the OSS-Note checked and installed and then use one of the two provided FMs? It should be possible to add it to a 740 system according to the correction instructions.
Cheers
Bärbel
10-27-2020 7:53 PM
Hi Jeff,
I tried this code in multiple systems (ECC & S/4)& it worked just fine. i.e. no dumps on multiple selection button.
REPORT ztest_001.
TABLES thead.
SELECT-OPTIONS : doc FOR thead-tdname.
Are you trying to do the same thing ?
10-27-2020 8:01 PM
Hello Piyush,
Yes sir I'm doing the same but I'm getting a dump:
Exception condition "INVALID_DYNPROFIELD" triggered.
Thank you,
Jeffrey
10-28-2020 5:33 PM
Hello Piyush,
I tried to run several test programs with same declarations, etc. and noticed that these are all working without dumps. When I investigated further, the dump was caused by an invalid text symbol assigned to a list box I overlooked when I was changing the code. My bad, working without dump now. thanks for the input.
10-28-2020 8:53 AM
Could you try something like
DATA: thead TYPE thead,
text_headers TYPE TABLE OF thead,
text_table TYPE text_lh.
PARAMETERS: object TYPE thead-tdobject.
SELECT-OPTIONS name FOR thead-tdname.
PARAMETERS: id TYPE thead-tdid,
spras TYPE thead-tdspras DEFAULT sy-langu.
START-OF-SELECTION.
SELECT * INTO CORRESPONDING FIELDS OF TABLE text_headers
FROM stxh
WHERE tdobject EQ object
AND tdname IN name
AND tdid EQ id
AND tdspras EQ spras.
CHECK sy-subrc EQ 0.
CALL FUNCTION 'READ_TEXT_TABLE'
IMPORTING
text_table = text_table
TABLES
text_headers = text_headers
EXCEPTIONS
wrong_access_to_archive = 1
OTHERS = 2.
CHECK sy-subrc EQ 0.<br>
Or paste the code you wrote that triggered the INVALID_DYNPROFIELD.
NB: You will get some problem if some of the fields have a conversion-exit and/or a different length, e.g. two fields with ALPHA conversion exit but different length will cause problems due to wrong number or trailing zeroes.
10-28-2020 5:57 PM
Thanks Raymond,
I tried to run several test programs with same declarations, etc. and noticed that these are all working without dumps. When I investigated further, the dump was caused by an invalid text symbol assigned to a list box I overlooked when I was changing the code. My bad, working without dump now. thanks for the input.
Regarding the without table reference, the dump confused me and made me think that using thead must not be allowed so as using custom table(dummy) I was surprised when I used mara in the same program to test and the dump occured as well. that's when I began to check further for the culprit and found the misplaced text symbol. I'm using now thead structure.
Thank you for your suggested solution, although I can't request for oss to implement the FM for now since I can use an alternative FM (READ_TEXT) and I'm a bit delayed. I have one question though..
In the solution you showed, my requirement is to use any document reason why I was confused cause I normally use a specific table (ex: mara) when getting values from the FM READ_TEXT. I checked STXH and it all came back to me. I remember using this table way back, With this type of requirement, I should be using STXH table right?
Thank you,
Jeffrey
10-29-2020 7:48 AM
For your question;
Yes, using STXH to validate user input with whole Abap SQL options, then looping at the resulting internal table with READ_TEXT should be ok.
For my warning:
When you use field such as VBRK-VBELN for example, you provide a field of the correct length and conversion exit, so, for example, ALPHA conversion will adjust user input in accordance (right jusstified, leading zero)
When using STXH or THEAD the field wont be adjusted,
SELECT *
FROM stxh
WHERE tdobject EQ @object
AND ltrim( tdname, '0' ) IN @name
AND tdid EQ @id
AND tdspras EQ @spras
INTO CORRESPONDING FIELDS OF TABLE @text_headers.
10-29-2020 4:28 PM
Thank you Raymond, I'll keep this in mind. I actually have last question where the keys I use to read_text gives result of more than one line of TDline (ex: 3 rows: hello world1, hello world2 and hello world3).
Now, the requirement is to print tdname followed by tdline depending on which format user selected, there are 2 formats (horizontal and vertical).
if Vertical ooutput should be:
1001(tdname)
hello world1
hello world2
hello world3
if Horizontal:
1001(tdname)(space) hello world1(space) hello world2 (space) hello world3
Problem i have now is there is no key in tdline that will allow me to use parallel cursor. I don't see any solution that will allow me to print
TDLINE outside readtext without using loop within a loop cause I'm currently looping in read text based on the select-options input (say 10 documents)..
is this one of the scenario where we can't use parallel cursor?
Thank you,
Jeffrey
10-29-2020 4:46 PM
Before the multi-read-text FM, some trick was used, look at mass reading standard texts stxh stx
10-29-2020 5:24 PM
Hi Raymond,
Thanks for the fast feedback, however, I think the approach will not give key to TDline...hence still loop within a loop without parallel cursor..
here are my steps:
1. Select from STXH where TDNAME IN select-options, OBJECT =p_object, ID = p_id store in ITAB.
now my internal table structure is: tdobject,tdname,id,spras...
2. loop at itab (looping each document used in TDNAM)
call read_text.
output table of read_text (tline) contain sometimes 3 for a loop ex: screenshot below.
endloop
screenshot:
example I have document 1001 and format is vertical, output should be:
1001
Reason for cancellation
(blank)
Tree Sap Error
if output is horizontal, output should be:
1001 reason for cancellation (blank) Tree Sap Error
hope you can clarify.
Thank you,
Jeffrey
10-30-2020 6:37 AM
Hi Raymond,
I understand now, it's not calling read_text. Anyway will the 2 FMS (READ_TEXT_TABLE and READ_MULITPLE_TEXTS) avoid loop within a loop?
The example uses a table as export parameter containing all names,key fields which is different from FM read text where it accepts only 1 value of each key per execution.. does the return table contain key field or just TDLINE for these 2 FMs?
Thank you,
Jeffrey
10-30-2020 7:23 AM
jeff.broodwar
Hi Jeff,
you'll always have to loop through the internal table TDLINE provided by READ_TEXT or one of the newer FMs where you'll end up with one entry per found TDNAME. This will be a deep structure as it also contains the TDLINE table. This however doesn't include something like a line number.
To make my own ALV-output sortable, I simply added a line number manually while building the internal table for the output:
The output then looks like this:
Listing the text elements vertically with one row per text line is usually best as there can be many lines for one TDNAME and you therefore don't really know how many columns you'd need to provide in the ALV-output. Field TDTXTLINES in THEAD contains the number of lines for that entry. But, cutting it off at e.g. 3 or 5 won't assure that whatever is deemed important within the text will show up in the output. And making the output having a flexible number of columns depending on the TDNAME which has the most lines opens another "can of worms" so to speak!
Cheers
Bärbel
10-30-2020 7:31 AM
In my sample READ_TEXT_TABLE will return an internal table, each record of the internal will contain THEAD, a flag and an internal table of TLINE
" ITCLH
" HEADER Types THEAD
" FUNCTION Types
" LINES Types TEXT_LINE_TAB
In any case, feel free to convert index of tline into a new field in your own structure.
10-30-2020 3:42 PM
Appreciate your inputs Raymond, also found the thread you shared interesting about decompressing and table STXL.
@Barbel, agree, can't avoid loop through TDLINE, thanks for sharing your ideas, appreciate it.
Thanks,
Jeffrey