11-30-2010 11:20 PM
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
12-01-2010 5: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.
12-01-2010 10:49 PM
Hello,
I created a subroutine for the read_text, delete_text portion of the code and placed the subroutine call inside the SAPScript. However, I retained the save_text in the main program. However, this makes no difference, it still displays the text of the first material for all cases.
Can you please let me know how to do this?
Thanks,
Rugmani
12-02-2010 4:30 AM
Hi,
What I meant was to get the texts using some selects on respective tables and not using SAVE_TEXT or some other FM.
Regards,
Srini.
12-09-2010 12:25 AM
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
12-14-2010 6: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.