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: 

SQ02 long texts extraction

former_member858887
Discoverer
0 Kudos

Hi,

I am at my first experience with coding in SQ02

I have tried to add a custom field to an infoset to get the long texts of purchasing lines.

To do this I have followd this link: https://blogs.sap.com/2013/09/19/faq-long-texts-in-plant-maintenance/

Unfortunately I'm stuck since I get this error:

Field "THEAD–TDNAME" is unknown. It is neither in one of the specified

tables nor defined by a "DATA" statement. "DATA" statement.

Can you give help/advise on how to solve the issue?

Thanks in advance

hereafter my code:

CLEAR l_texts.

***************************************************

* Data definition for input parameters

***************************************************

data:


name LIKE thead–tdname,

spras like STXH–tdspras.

***************************************************

* Data definition for output

***************************************************

DATA BEGIN OF txtheader.

INCLUDE STRUCTURE thead.

DATA END OF txtheader.

DATA BEGIN OF txtlines OCCURS 15.

INCLUDE STRUCTURE tline.

DATA END OF txtlines.

***************************************************

* Getting parameter ‘name’ which in case of operation long text

* is combination of mandant, routing number and general counter

***************************************************

CONCATENATE ekpo–ebeln ekpo-ebelp

INTO name.

***************************************************

* Determining language which has been used for long text

* (assuming, that there is only one used #

***************************************************

Select single TDspras into spras from STXH where TDOBJECT = ‘EKPO’

AND TDID = ‘F03’ and TDNAME = name.

***************************************************

* Reading long text into internal table

***************************************************

CALL FUNCTION ‘READ_TEXT’

EXPORTING

client = sy–mandt

id = ‘F03’

language = SPRAS

name = name

object = ‘EKPO’

archive_handle = 0

* LOCAL_CAT = ‘ ‘

IMPORTING

header = txtheader

TABLES

lines = txtlines

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 <> 0.

* Implement suitable error handling here

ENDIF.

***************************************************

* Concatenating long text rows from internal table

* into one, output field

***************************************************

LOOP AT txtlines.

CONCATENATE ltext txtlines–tdline INTO l_texts SEPARATED BY space.

ENDLOOP.

REFRESH txtlines.

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos

As you use like, you reference should also be a variable of your program, so either

  • Use DATA: name TYPE thead-tdname. (direct ddic ref)
  • Define also thead as a variable DATA: thead TYPE thead.
  • Use DATA: name like txtheader-thead-tdname. as you already define this variable
  • etc.
5 REPLIES 5

anne-petteroe
Community Manager
Community Manager
0 Kudos

Hello Pietro,

Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with https://community.sap.com/resources/questions-and-answers, as it provides tips for preparing questions that draw responses from our members.

Feel free to take our Q&A tutorial at https://developers.sap.com/tutorials/community-qa.html as well, as that will also help you when preparing questions for the community.

Should you wish, you can revise your question by selecting Actions, then Edit.

Kind regards,
Anne

raymond_giuseppi
Active Contributor
0 Kudos

As you use like, you reference should also be a variable of your program, so either

  • Use DATA: name TYPE thead-tdname. (direct ddic ref)
  • Define also thead as a variable DATA: thead TYPE thead.
  • Use DATA: name like txtheader-thead-tdname. as you already define this variable
  • etc.

0 Kudos

Hi,

I am really a newbie on ABAP. I have tried but without success.

Would you be so kind to show me directly on the code how you would modify it to let it run properly?

It would be much appreciated

Thanks in advance

Pietro

Former Member

Hi, I did a test in SQ02 and it looks like you copied/pasted the code in the link you gave.

But when I write the declaration myself, it works. Looking closer, I see that the "-" between THEAD and TDNAME is slightly longer in the copy/pasted version and is not recognized. Delete the "-" and write it directly with your keyboard. Normally it will work.

But verify all the other fields because I thinks they will have the same problem.

Sandra_Rossi
Active Contributor
0 Kudos

Please edit your question (Actions>Edit), select your code and press the button [CODE], which makes the code appear colored/indented, it'll be easier for people to look at it. Thanks!