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

Field Symbol

Former Member
0 Likes
2,625

Hi all

Im using the follow code in a user exit to retrieve the text typed for a certain item of the transacatio ME51N.

.

.

field-symbols <ztext> type any " or

field-symbols <ztext2> type standard table.

assign ('(SAPLMMTE)gt_control') to <ztext>.

Even If I have data stored in the gt_control, When I check sy-subrc, I get sy-subrc <> 0 .

One of the field of this gt_control is a structure type mmpur_textlines where is in fact the data I need to test.

Something like: <ztext>-textlines-tdline must be <> 0 .

Any idea how can I do this !?

Many thanks.

Cristina

1 ACCEPTED SOLUTION
Read only

venkata_ramisetti
Active Contributor
0 Likes
2,305

Hi,

field-symbol <ztext> type should be gt_control. Otherwise though it fetches data, it doesn't recognize its data definition.

Example:

  • Data declarations

CONSTANTS: c_ vbak (14) type c value '(SAPMV45A)VBAK'.

FIELD-SYMBOLS: < fs_vbak> type vbak.

  • Now we assign the field symbol to point to the VBAK structure which

  • is in SAPMV45A

ASSIGN ( c_vbak) to < fs_vbak>.

  • Now we can perform coding based on the values in vbak

IF < fs_vbak>- vkorg = 'FR01'.

ENDIF.

Thanks,

Ramakrishna

Hi all

Im using the follow code in a user exit to retrieve the text typed for a certain item of the transacatio ME51N.

.

.

field-symbols <ztext> type any " or

field-symbols <ztext2> type standard table.

assign ('(SAPLMMTE)gt_control') to <ztext>.

Even If I have data stored in the gt_control, When I check sy-subrc, I get sy-subrc <> 0 .

One of the field of this gt_control is a structure type mmpur_textlines where is in fact the data I need to test.

Something like: <ztext>-textlines-tdline must be <> 0 .

Any idea how can I do this !?

Many thanks.

Cristina

13 REPLIES 13
Read only

Former Member
0 Likes
2,305

Sorry, the <ztext>-textlines-tdline must be <> ''.

Read only

venkata_ramisetti
Active Contributor
0 Likes
2,306

Hi,

field-symbol <ztext> type should be gt_control. Otherwise though it fetches data, it doesn't recognize its data definition.

Example:

  • Data declarations

CONSTANTS: c_ vbak (14) type c value '(SAPMV45A)VBAK'.

FIELD-SYMBOLS: < fs_vbak> type vbak.

  • Now we assign the field symbol to point to the VBAK structure which

  • is in SAPMV45A

ASSIGN ( c_vbak) to < fs_vbak>.

  • Now we can perform coding based on the values in vbak

IF < fs_vbak>- vkorg = 'FR01'.

ENDIF.

Thanks,

Ramakrishna

Read only

0 Likes
2,305

Hi Ramakrishna

Thank you very much for your reply.

The problem is that the gt_control is still unknown in my user exit, if I declare the way you suggested I get a dump.

I get the 'gt-control' this way

assign ('(SAPLMMTE)gt_control') to <ztext>.

I hope you understand what I mean.

Any idea how can I do this?

Many thanks

Read only

0 Likes
2,305

Hi,

Can you give us the user-exit and code that u are trying?

I will provide the correct solution.

Thanks,

Ramakrishna

Read only

0 Likes
2,305

Hi

Many thanks again for your help

What I need to do is a validation when savind a new PO in the transaction ME51N. The item text field must be <> ' ' when p_mereq_item-matnr = ' '.

Im using the user exit EXIT_SAPLMEREQ_005.

I could use the function READ_TEXt if the PO was already saved, but in this case it it a new

PO and the text is still not saved in the table STXH.

So, debugging the program I found out that this text is in stored in the table gt_control.

This is the code Im trying to write:

CONSTANTS: c_control (14) type c value '(SAPLMMTE)gt_control'

FIELD-SYMBOLS: <fs_control> TYPE table.

check SY-TCODE = 'ME51N' and SY-UCOMM = 'MESAVE'.

IF P_MEREQ_ITEM-MATNR = ' '.

ASSIGN (c_control) to <fs_control>.

IF <fs_control>TEXTLINES[1]-TDLINE = ' '.

MESSAGE E264(ZMM).

ENDIF.

ENDIF.

Many thanks.

Read only

0 Likes
2,305

Hi

may be this would work out.

IF <fs_control>-TEXTLINES[1]-TDLINE is initial.

MESSAGE E264(ZMM).

ENDIF.

Regards

Navneet

Read only

0 Likes
2,305

in SD the following approach worked fine to retrieve text form text buffer :

catalog is defined in SAP like :

data begin of catalog occurs 50.

include structure tcatalog.

data end of catalog.

import catalog from memory id 'SAPLSTXD'

catalog-function - contains 'I' for INSERT, 'U' for update ...

then you need to build memory key for text contents (header, lines) and import texts, something like :

loop at catalog.

if ( catalog-tdname = dummy or catalog-tdname = vbak-vbeln )

and ( catalog-function = 'I' "inserting text

or catalog-function = 'U' )."updating text

mem_id = 'SAPLSTXD'. mem_id+8(6) = catalog-id.

endif.

*read text lines from memory into internal table zlines

import thead to zheader tline to zlines

from memory id mem_id.

check where-used for catalog internal table to see how it's used.

In your case (your assign logic) - if you want to get access to internal table - you need to use something like :

CONSTANTS: c_control (14) type c value '(SAPLMMTE)gt_control[]'

NOTE: gt_control[] <- this can help.

Read only

0 Likes
2,305

try capitals:

CONSTANTS: c_control (14) type c value '(SAPLMMTE)GT_CONTROL'.

Read only

0 Likes
2,305

Hi Cristina,

I am very sorry for the late response.

At last I got the solution for this. It took me 5 dedicated hours to get the solution.

Few observations in my research.

1. User-exit EXIT_SAPLMEREQ_005 is not usefull for your requirement.

2. You need not use field-symbol at all.

The above two points misguided us in finding solution.

You have to do the following steps to incorporate your requirement.

1. Use user-exit EXIT_SAPLMEREQ_010 to validate the item text.

2. Import Parameter IM_REQ_HEADER is an object reference, which contains every thing about the object including item texts.

3. write the below code in the user-exits program.

&----


*& Include ZXM02U12 *

&----


DATA: V_TDID TYPE TDID,

X_IM_TEXTTYPE TYPE MMPUR_TEXTTYPES,

EX_TEXTLINES TYPE MMPUR_T_TEXTLINES,

EX_TEXT_FORMATTED TYPE MMPUR_BOOL,

OBJ_RE_ITEMS TYPE MMPUR_REQUISITION_ITEMS,

ITEM_LINE TYPE MMPUR_REQUISITION_ITEM,

X_MEREQ_ITEM TYPE MEREQ_ITEM,

ITEM TYPE REF TO IF_PURCHASE_REQUISITION_ITEM,

OBJ_IM_REQ_ITEM TYPE REF TO IF_PURCHASE_REQUISITION_ITEM.

V_TDID = 'B01'. " Text Id for Item Texts

*Get the table that contains PR Item object references

CALL METHOD IM_REQ_HEADER->GET_ITEMS

  • EXPORTING

  • IM_AUTH_CHECK = MMPUR_NO

  • IM_RELEASE_OP = MMPUR_NO

RECEIVING

RE_ITEMS = OBJ_RE_ITEMS.

LOOP AT OBJ_RE_ITEMS INTO ITEM_LINE.

*Get the each Item object reference

ITEM = ITEM_LINE-ITEM.

*Get the PR Item details to check whether material is blank

CALL METHOD ITEM->GET_DATA

RECEIVING

RE_DATA = X_MEREQ_ITEM.

*Item text should not be blank if the material is blank

IF X_MEREQ_ITEM-MATNR IS INITIAL.

*get the item text for each PR item

CALL METHOD ITEM->IF_LONGTEXTS_MM~GET_TEXT

EXPORTING

IM_TDID = V_TDID

  • IM_TEXTTYPE = X_IM_TEXTTYPE

IMPORTING

EX_TEXTLINES = EX_TEXTLINES

EX_TEXT_FORMATTED = EX_TEXT_FORMATTED .

*Check for PR Item text is blank or not?(check table is empty or not)

IF EX_TEXTLINES[] IS INITIAL.

MESSAGE E264(ZMM).

ENDIF.

ENDIF.

ENDLOOP.

Please let me([email protected]) know if you have issues.

Thanks,

Ramakrishna

Read only

0 Likes
2,305

Hi Ramakrishna

Thank you very much for your time and the solution.

But Im afraid that I will not be able to implement it.

By using your code, in the user-exit EXIT_SAPLMEREQ_010 as you suggested, I got the following errors:

Class "IF_PURCHASE_REQUISITION_ITEM" does not contain an interface, however there is a similary-named interface "IF_TEXT_MM"

An if I replace and use IF_TEXTS_MM

CALL METHOD ITEM->IF_TEXTS_MM~GET_TEXT

I dont have the exporting parameter

V_TDID

The parameters avaibles are

*EXPORTING

EX_TEXTTYPES

EX_TEXTLINES .

I guess it is because Im using the version 4.6C !?

Many many thanks again.

Cristina

Read only

0 Likes
2,305

Hi Cristina,

I am very sorry Cristina. I worked on SAP4.7 version. I am able to validate the material and item texts also.

Probably you are correct. The user-exit EXIT_SAPLMEREQ_010 doesnot have import parameter IF_PURCHASE_REQUISITION_ITEM in 4.6C.

Do one thing. Write the same above code in the user-exit EXIT_SAPLMEREQ_005.

Probably it works here. because you have import paramter IM_REQ_HEADER here. So try to put the same logic here.

Thanks,

Ramakrishna

Read only

0 Likes
2,305

hey, Cristina... I had already suggested using capitals! Why no points?

Read only

Clemenss
Active Contributor
0 Likes
2,305

Christina,

did you try uppercase?

assign ('(SAPLMMTE)GT_CONTROL') to <ztext>.

might do better.

And sure, it is true: The field-symbol should be of the same table type as GT_CONTROL. As this type is declared in the program, you could either copy it or use further assigns for the field(s) you want to use:

<pre>

field-symbols:

<table> type table,

<line> type any,

<field> type any.

  • something like

assign ('(SAPLMMTE)GT_CONTROL') to <table>.

loop at <table> assigning <line>.

assign component 'OBJECT'

of structure <line> to <field>.

write: / <field>.

endloop.

</pre>

Note: GT_CONTROL is a 'deep' table containing subtables. Handle them if required the same way: untyped field-symbols for simple fields, tab-typed field-symbols for internal tables.

Hope you get it running!

Regards,

Clemens