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

matchcode

Former Member
0 Likes
1,316

I want to create matchcode(Search help) for Purchase Order Text(Long text) of a material.

I know the steps to create matchcode for table fields, but do not know how to create for this long text which can be read with READ_TEXT FM.

Please help me with the steps to create this search help.

Regards,

Pratibha

12 REPLIES 12
Read only

Vinod_Chandran
Active Contributor
0 Likes
1,213

Hi Pratibha,

I think this can be achieved by using the search help exit. Under the search help parameter, give a parameter to which you want to populate the PO long text (say POTEXT and give a data element). This parameter can be later populated using the search help exit. Please see the function module F4IF_SHLP_EXIT_EXAMPLE. This can be copies to your Z name range and do the modification. In it check the section 'STEP SELECT (Select values)'.

Should you require more clarification please let me know.

Thanks

Vinod

Read only

0 Likes
1,213

Hi Vinod,

Thanks for reply.

Shall I enter only one search help parameter (POTEXT)?

Or MATNR also required? Because based on Long text entered I want to display Material Number.

As well shall I just uncomment STEP SELECT section of FM or I have to add some extra code in it.

Thanks

Pratibha.

Read only

0 Likes
1,213

Hi,

Please follow these steps. There is a slight correction from my previous mail. Instead of the SELECT step, you have to write your code in the DISP (Display Values) stage. In this step you get all the values in the internal table RECORD_TAB. This has got one one field called 'String'. You can use the substring option to take the desired value.

Now answering your questions.

You have to have all the fields in the serach help which are needed for the READ_TEXT function module. And the POTEXT field.

For example

VBELN 1 1 VBELN_VL

POSNR 2 2 POSNR_VL

MATNR 3 3 MATNR

POTEXT 4 4 CHAR40

Now you have to code in the 'Display values' section to populate the value of POTEXT in the internal table RECORD_TAB. For this declare a structure in the function module with all the fields you have declared in the search help. Populate this structure inside the LOOP and modify RECORD_TAB using this.

if callcontrol-step = 'DISP'.

loop at record_tab.

call function 'READ_TEXT'

....

....

Populate the record_tab

endloop.

exit.

endif.

Thanks

Vinod

Read only

Former Member
0 Likes
1,213

i don't know whether this is write way or not , but i think it can be helpful.

if you have used PFCG, there we enter detail description in text_editor.

this description is saved in a database table as line by line along with line number,

so if you can do something like this it can be very easy to attach search help

regards.

Read only

0 Likes
1,213

HI Vinod,

Which function group you are using for this Function Module?

Thanks,

Pratibha

Read only

0 Likes
1,213

Any of the Z* or Y* function group. You can use any of the existing one or a new one.

Read only

0 Likes
1,213

Vinod,

Here is a code for Function Module

-


FUNCTION Z_MATNR_MATCHCODE.

*"----


""Local interface:

*" TABLES

*" SHLP_TAB TYPE SHLP_DESCR_TAB_T

*" RECORD_TAB STRUCTURE SEAHLPRES

*" CHANGING

*" VALUE(SHLP) TYPE SHLP_DESCR_T

*" VALUE(CALLCONTROL) LIKE DDSHF4CTRL STRUCTURE DDSHF4CTRL

*"----


DATA: BEGIN OF minfo OCCURS 0, " parallel table to

Matnr LIKE MARA-Matnr, " record_tab containing

POTEXT(132) , " the information about the seats

END OF minfo.

DATA: BEGIN OF IT_TEXT OCCURS 100.

INCLUDE STRUCTURE TLINE.

DATA: END OF IT_TEXT.

DATA: TEMP_TEXT(72).

  • EXIT immediately, if you do not want to handle this step

IF CALLCONTROL-STEP <> 'SELONE' AND

CALLCONTROL-STEP <> 'SELECT' AND

" AND SO ON

CALLCONTROL-STEP <> 'DISP'.

EXIT.

ENDIF.

*"----


  • STEP SELONE (Select one of the elementary searchhelps)

*"----


  • This step is only called for collective searchhelps. It may be used

  • to reduce the amount of elementary searchhelps given in SHLP_TAB.

  • The compound searchhelp is given in SHLP.

  • If you do not change CALLCONTROL-STEP, the next step is the

  • dialog, to select one of the elementary searchhelps.

  • If you want to skip this dialog, you have to return the selected

  • elementary searchhelp in SHLP and to change CALLCONTROL-STEP to

  • either to 'PRESEL' or to 'SELECT'.

IF CALLCONTROL-STEP = 'SELONE'.

  • PERFORM SELONE .........

EXIT.

ENDIF.

*"----


  • STEP PRESEL (Enter selection conditions)

*"----


  • This step allows you, to influence the selection conditions either

  • before they are displayed or in order to skip the dialog completely.

  • If you want to skip the dialog, you should change CALLCONTROL-STEP

  • to 'SELECT'.

  • Normaly only SHLP-SELOPT should be changed in this step.

IF CALLCONTROL-STEP = 'PRESEL'.

  • PERFORM PRESEL ..........

EXIT.

ENDIF.

*"----


  • STEP SELECT (Select values)

*"----


  • This step may be used to overtake the data selection completely.

  • To skip the standard seletion, you should return 'DISP' as following

  • step in CALLCONTROL-STEP.

  • Normally RECORD_TAB should be filled after this step.

  • Standard function module F4UT_RESULTS_MAP may be very helpfull in this

  • step.

IF CALLCONTROL-STEP = 'SELECT'.

  • PERFORM STEP_SELECT TABLES RECORD_TAB SHLP_TAB

  • CHANGING SHLP CALLCONTROL RC.

  • IF RC = 0.

  • CALLCONTROL-STEP = 'DISP'.

  • ELSE.

  • CALLCONTROL-STEP = 'EXIT'.

  • ENDIF.

EXIT. "Don't process STEP DISP additionally in this call.

ENDIF.

*"----


  • STEP DISP (Display values)

*"----


  • This step is called, before the selected data is displayed.

  • You can e.g. modify or reduce the data in RECORD_TAB

  • according to the users authority.

  • If you want to get the standard display dialog afterwards, you

  • should not change CALLCONTROL-STEP.

  • If you want to overtake the dialog on you own, you must return

  • the following values in CALLCONTROL-STEP:

  • - "RETURN" if one line was selected. The selected line must be

  • the only record left in RECORD_TAB. The corresponding fields of

  • this line are entered into the screen.

  • - "EXIT" if the values request should be aborted

  • - "PRESEL" if you want to return to the selection dialog

  • Standard function modules F4UT_PARAMETER_VALUE_GET and

  • F4UT_PARAMETER_RESULTS_PUT may be very helpfull in this step.

IF CALLCONTROL-STEP = 'DISP'.

  • PERFORM AUTHORITY_CHECK TABLES RECORD_TAB SHLP_TAB

  • CHANGING SHLP CALLCONTROL.

loop at minfo.

DATA: NAME LIKE THEAD-TDNAME.

REFRESH : IT_TEXT.

MOVE minfo-MATNR TO NAME.

CALL FUNCTION 'READ_TEXT'

EXPORTING

  • CLIENT = SY-MANDT

id = 'BEST'

language = SY-LANGU

name = NAME

object = 'MATERIAL'

  • ARCHIVE_HANDLE = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

tables

lines = IT_TEXT

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.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

minfo-POTEXT = IT_TEXT.

endloop.

EXIT.

ENDIF.

CALL FUNCTION 'F4UT_PARAMETER_RESULTS_PUT'

EXPORTING

parameter = 'POTEXT'

  • OFF_SOURCE = 0

  • LEN_SOURCE = 0

  • VALUE =

FIELDNAME = 'POTEXT'

tables

shlp_tab = shlp_tab

record_tab = record_tab

SOURCE_TAB = minfo

changing

shlp = shlp

callcontrol = callcontrol

EXCEPTIONS

PARAMETER_UNKNOWN = 1

OTHERS = 2

.

IF sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFUNCTION.

-


Changing TAB has

SHLP TYPE SHLP_DESCR_T

CALLCONTROL LIKE DDSHF4CTRL

-


Tables Tab has

SHLP_TAB TYPE SHLP_DESCR_TAB_T

RECORD_TAB LIKE SEAHLPRES

-


In Search Help:

Search Help parameters are

POTEXT (data element TDLINE) with IMP EXP checked

MATNR (data element MATNR) with IMP EXP checked

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

When I test this search help, and enter value in POtext parameter, No result is fetched.

Is there anything wrong in FM source code.

Regards,

Pratibha

Read only

0 Likes
1,213

Hi,

I have made few correction. The text can contain many lines, but in the match code we can display only one line. I am taking the first line. Please see the code.

You have to loop thru the RECORD_TAB internal table, not minfo.

DATA DECLARATION

----


DATA: BEGIN OF minfo, " parallel structure to

matnr LIKE mara-matnr, " record_tab containing

potext(132) , " the information about the seats

END OF minfo.

DATA: BEGIN OF it_text OCCURS 100.

INCLUDE STRUCTURE tline.

DATA: END OF it_text.

DATA: temp_text(72).

DATA: name LIKE thead-tdname,

w_tabix LIKE sy-tabix.

----


CODE

----


IF callcontrol-step = 'DISP'.

LOOP AT record_tab.

w_tabix = sy-tabix.

MOVE-CORRESPONDING record_tab TO minfo.

REFRESH : it_text.

MOVE minfo-matnr TO name.

CALL FUNCTION 'READ_TEXT'

EXPORTING

id = 'BEST'

language = sy-langu

name = name

object = 'MATERIAL'

TABLES

lines = it_text

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.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

READ TABLE it_text INDEX 1.

IF sy-subrc = 0.

minfo-potext = it_text-tdline.

ENDIF.

ENDIF.

MODIFY record_tab INDEX w_tabix.

ENDLOOP.

EXIT.

ENDIF.

----


Also change the order of the fields in the serch help.

MATNR (data element MATNR) with IMP EXP checked

POTEXT (data element TDLINE) with IMP EXP checked

What is the Selection method (table) you have given in the search help?

Try this and let me know if you have problems.

Thanks

Vinod

Read only

0 Likes
1,213

Hi Vinod,

Thanks for the reply.

Which table shall I use as Selection method (table) and TEXT table?

System not accepting TLINE.

Thanks,

Pratibha

Read only

0 Likes
1,213

Hi Pratibha,

From which table you are getting the material number?

This you have to give as the section method.

Thanks

Vinod

Read only

0 Likes
1,213

Vinod,

If I provide MARA table.

I get warning Serach help parameter POTEXT does not occur in selection methid.

After executing matchcode, I am entering POTEXT for MAterial number serach.

I get an error TEXT ID 'BEST' Language EN not found.

System hangs after this point.

Regards,

Pratibha.

Read only

0 Likes
1,213

Hi All,

Does anyone here has an idea on how to retrieve material number based on part of purchase order long text entered. Search help for PO text. The code above does not work.

Thanks,

Pratibha