Skip to Content
author's profile photo Former Member
Former Member

Incorrect text printed from SAPScript

Hello,

I have added some code to the 'Pick list' print out of the production order. This code will read the 'Inspection text' from the material master and print it for all materials required in that production order. The code that I added is:

CLEAR flg_head.

LOOP AT index_tab.

REFRESH: lt_lines.

CLEAR: lv_index,

lv_lncnt.

CALL FUNCTION 'READ_TEXT'

EXPORTING

client = sy-mandt

id = 'ST'

language = sy-langu

name = 'ZMATQM'

object = 'TEXT'

TABLES

lines = lt_lines1

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.

IF sy-subrc = 0.

CALL FUNCTION 'DELETE_TEXT'

EXPORTING

client = sy-mandt

id = 'ST'

language = sy-langu

name = 'ZMATQM'

object = 'TEXT'

EXCEPTIONS

not_found = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE 'Text could not be deleted' TYPE 'E'.

ENDIF.

ENDIF.

REFRESH lt_lines1.

CLEAR lt_lines1.

  • Fill DDIC-Strutcure of component

READ TABLE resbd_tab INDEX index_tab-index_cmp.

resbd = resbd_tab.

lv_mat = resbd_tab-matnr.

CALL FUNCTION 'READ_TEXT'

EXPORTING

client = sy-mandt

id = 'PRUE'

language = sy-langu

name = lv_mat

object = 'MATERIAL'

TABLES

lines = lt_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.

REFRESH lt_lines.

CLEAR lt_lines.

ENDIF.

SEARCH lt_lines FOR 'Prod:' AND MARK.

IF sy-subrc = 0.

lv_index = sy-tabix + 1.

ENDIF.

IF lv_index IS NOT INITIAL.

gt_head-tdobject = 'TEXT' .

gt_head-tdid = 'ST' .

gt_head-tdspras = sy-langu.

gt_head-tdlinesize = 132.

gt_head-tdname = 'ZMATQM'.

LOOP AT lt_lines FROM lv_index.

APPEND lt_lines TO lt_lines1.

ENDLOOP.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

client = sy-mandt

header = gt_head

savemode_direct = 'X'

owner_specified = ' '

TABLES

lines = lt_lines1

EXCEPTIONS

id = 1

language = 2

name = 3

object = 4

OTHERS = 5.

IF sy-subrc = 0.

  • CALL FUNCTION 'COMMIT_TEXT'

  • EXPORTING

  • object = gt_head-tdobject

  • name = gt_head-tdname.

COMMIT WORK.

ELSE.

MESSAGE 'Text could not be saved' TYPE 'E'.

ENDIF.

  • at first entry print print description

IF flg_head IS INITIAL.

IF print_co-barco IS INITIAL.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'QM_DATA_HDR'

window = 'MAIN'.

ELSE.

  • reservation BC on each page

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'BARCODE_RSNUM'

function = 'SET'

type = 'TOP'

window = 'MAIN'.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'QM_DATA_BC_HDR'

window = 'MAIN'.

ENDIF.

flg_head = const-flg_yes.

ENDIF.

  • Print material instructions

CALL FUNCTION 'CONTROL_FORM'

EXPORTING

command = 'PROTECT'.

IF print_co-barco IS INITIAL.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'QM_DATA'

window = 'MAIN'.

ELSE.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'QM_DATA_BC'

window = 'MAIN'.

ENDIF.

CALL FUNCTION 'CONTROL_FORM'

EXPORTING

command = 'ENDPROTECT'.

  • print material text

PERFORM pppr_print_cmp_text.

ENDIF.

ENDLOOP.

This code prints the text correctly for the first material for which it finds the text. However, for all subsequent materials it prints the text of the first material. Upon debugging, I see that after 'SAVE_TEXT' the text has been updated but the SAPScript form does not seem to recognize the updated text and it prints the first text always.

Please guide me on how to solve this issue.

Thanks,

Rugmani

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 01, 2010 at 05:08 AM

    Hi,

    There is no other alternative other than write code in a SUBROUTINE POOL to get the texts

    (I also faced the same issue , SAVE_TEXT does not get the text instantly)

    and call the perform from the script.

    Regards,

    Srini.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hello,

      I have been trying a couple of options including the 'SELECT' option suggested. I also tried using 'IMPORT' to read the text into a table.

      DATA: itab TYPE STANDARD TABLE OF tline WITH HEADER LINE.

      IMPORT tline TO itab

      FROM DATABASE stxl(tx)

      TO wa_indx

      CLIENT sy-mandt

      ID stxl_id

      IGNORING CONVERSION ERRORS.

      I looped through this table (itab) and called the SAPScript function modules where I tried printing the table contents (itab-tdline). However, the table is not visible within the SAPScript and so it does not print any text.

      Any help is greatly appreciated.

      Thanks,

      Rugmani

  • author's profile photo Former Member
    Former Member
    Posted on Dec 14, 2010 at 06:44 PM

    I decided to use internal tables and pass the table contents to the SAPScript for printing on the form.

    Thanks for all your help.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.