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

ME32K: read text before saving

marcela_martinez
Participant
0 Likes
3,197

Hi everybody,

I have checked some threads that I think could help me with my problem but I have no luck. My be somebody can help me...

I need to check a specific header text at ME32K transaction before saving. If the user complete it everything is ok, if not an error message appears. I solved this with an exit, but the problem is that the text is not saved at this point, I need to get it from memory and I'm not solving this point.

Do you have any ide to solve this?

Kind regards!

Hi

If the text is deleted, the READ_TEXT doesn't return the text?

Are you sure?

Max

12 REPLIES 12
Read only

Former Member
0 Likes
2,491

Hi

You can use the fm READ_TEXT, it always returns the current text, that means:

- If the text is not saved yet, it returns the text from buffer

- if the text is saved, it return the text from DB

Max

Read only

0 Likes
2,491

Thanks Max but READ_TEXT is not useful for me. If the existing text was deleted READ_TEXT brings the old one.

I need to read which the user does: if the text was deleted I need to know it.

Thx a lot!

Read only

0 Likes
2,491

Hi

If the text is deleted, the READ_TEXT doesn't return the text?

Are you sure?

Max

Read only

0 Likes
2,491

I'm sure... READ_TEXT returns the text which is saved.

Thx.

Read only

0 Likes
2,491

Uhm

I've inserted the following code in the exit for the checking of Purchase Order:

DATA: L_HEADER TYPE MEPOHEADER.
  DATA: L_NAME   TYPE THEAD-TDNAME.

  L_HEADER = IM_HEADER->GET_DATA( ).

  DATA: LINES TYPE STANDARD TABLE OF  TLINE.


  MOVE L_HEADER-EBELN TO L_NAME.

  CALL FUNCTION 'READ_TEXT'
    EXPORTING
*     CLIENT                        = SY-MANDT
      ID                            = 'F91'
      LANGUAGE                      = 'I'
      NAME                          = L_NAME
      OBJECT                        = 'EKKO'
    TABLES
      LINES                         = 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 <> 0.
  ENDIF.

In the lines I can see the modification I've done in the text before saving the document, I mean I see the current text

Max

Read only

0 Likes
2,491

Thanks Max!!

Can you tell me which is IM_HEADER?

I'm just going to copy exactly which you said, I did it before but not with im_header->get_data( )

Thanks again!

Read only

0 Likes
2,491

Max, with your suggested code, al ME32K user-exit the text is the old one

Read only

0 Likes
2,491

Hi

That is the BADI for PO (ME22N), but the contract should be very similar, I'm trying to ckeck for the contract, but I don't know if there's an exit developed

Max

Read only

0 Likes
2,491

Which exit are you using?

Max

Read only

0 Likes
2,491

Exit MM06E005

FM EXIT_SAPMM06E_012

Read only

0 Likes
2,491

Uhm ok

That exit is developed for PO, so I've inserted my code in that exit:

DATA: L_NAME TYPE THEAD-TDNAME.
  DATA: TLINES TYPE STANDARD TABLE OF TLINE.

  MOVE I_EKKO-EBELN TO L_NAME.

  CALL FUNCTION 'READ_TEXT'
    EXPORTING
*     CLIENT                        = SY-MANDT
      ID                            = 'K01'
      LANGUAGE                      = 'I'
      NAME                          = L_NAME
      OBJECT                        = 'EKKO'
*     ARCHIVE_HANDLE                = 0
*     LOCAL_CAT                     = ' '
*   IMPORTING
*     HEADER                        =
    TABLES
      LINES                         = TLINES
*   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.

Now I'm go to the header text, do a modification to the text ID K01 and press the CHECKING in order to trigger the exit.

If I run the process above in debug way, in table TLINES I can see the current text (so all modifications I've done)

Max

Read only

marcela_martinez
Participant
0 Likes
2,491

Thanks Maxi for hour help, it was very helpful.

I solve it by another way:

I get if the text was modified or not with an ASSIGN. I put down a piece of code.

FIELD-SYMBOLS: <fs_control> TYPE ANY TABLE,

<wa_control> TYPE ANY,

<fs_aux> TYPE ANY TABLE,

<fs_aux2> TYPE ANY.

...

...

...

ASSIGN ('(SAPMM06E)theadtab[]') TO <fs_control>.

IF sy-subrc EQ 0.

LOOP AT <fs_control> ASSIGNING <wa_control>.

wal_thead = <wa_control>.

IF wal_thead-tdobject EQ cl_ekko AND wal_thead-tdid EQ cl_k24.

IF wal_thead-tdtxtlines EQ 0.

vl_fill = cl_x.

EXIT.

ENDIF.

ENDIF.

ENDLOOP.

ENDIF.

Thanks & regards!