‎2009 Jul 22 8:58 AM
Hi all,
I have a problem with SapScript, because I'm trying to add dinamic text. I have two options:
1. I use the sentence
*IN THE SAPSCRIPT:*
/: INCLUDE &LOT& OBJECT QPRUEFLOS ID QALS LANGUAGE &NAST-SPRAS&
to add the text corresponding to the object prueflos LOT. This sentence writes all lines of the text but I don´t need the first two. It's possible use this sentence and say it what lines i want to write.
2. I used the next code
*IN THE SAPSCRIPT:*
/: PERFORM observation IN PROGRAM ZQAMV
/: USING &LOT&
/: CHANGING &TEXT1&
..........
/: CHANGING &TEXT11&
/: ENDPERFORM
*IN THE PERFORM*
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = 'QALS'
language = sy-langu
name = G_LOT
object = 'QPRUEFLOS'
TABLES
lines = it_lines
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
LOOP AT it_lines INTO wa_lines.
CASE sy-tabix.
WHEN 1.
MOVE wa_lines-tdline TO cadena.
output_table-name = 'TEXTO1'.
output_table-value = cadena.
MODIFY output_table INDEX 1.
.........
WHEN 11.
MOVE wa_lines-tdline TO cadena.
output_table-name = 'TEXTO11'.
output_table-value = cadena.
MODIFY output_table INDEX 11.
ENDCASE.
ENDLOOP.
But it doesn´t work well because if the text has more than 11 lines, the form doesn´t write all lines and the text of a line is cut, only show 50 characters.
Please any can help me, THANKS
‎2009 Jul 23 3:41 PM
Hi Lydia,
you may try this approach:
in Program
=========
do your method to populate a text table with little modification:
loop at it_lines ...
if sy-tabix = 1 or sy-tabix = 2.
continue.
endif.
..
append output_table. {use append instead of modify, so no need to think about the index}
endloop.
{and add a process which does loop the output_table, and write new element on the SAPScript}
ex:
loop at output_table .
{call the write function }
endloop.
in SAPScrip:
=========
you can add new element to write your text table. ex: text_elm
Hope it can help u,
Regards,
Oki
‎2009 Jul 22 10:07 AM
Hi LydiaMM,
The text may conaitn any number of lines.So Its not good to use the case statement.
So better to try like this:
LOOP AT it_lines INTO wa_lines.
MOVE wa_lines-tdline TO cadena.
output_table-name = 'TEXTO1'.
output_table-value = cadena.
MODIFY output_table sy-tabix.
ENDLOOP.
SO the above code works for all the lines irrespective of totallines.
And if u see the case of truncating the characters (getting only upto 50 characters),The problem could be solved with either of the below two:
1.Make sure that the length of cadena (datatype) is atleast of tdline's length.
2.Or try to replace the tdline reference with similar but with more length datatype reference.
Hope this solves your problem.
Regards,
Rama chary.P
‎2009 Jul 23 2:33 PM
Hi,
I wrote your code in my program and it doesn't work, because only appear the first line of recover text, and i only fill the table output with lines 3, 4, 5... not 1 and 2.
Any other ideas. Thanks
‎2009 Jul 23 3:41 PM
Hi Lydia,
you may try this approach:
in Program
=========
do your method to populate a text table with little modification:
loop at it_lines ...
if sy-tabix = 1 or sy-tabix = 2.
continue.
endif.
..
append output_table. {use append instead of modify, so no need to think about the index}
endloop.
{and add a process which does loop the output_table, and write new element on the SAPScript}
ex:
loop at output_table .
{call the write function }
endloop.
in SAPScrip:
=========
you can add new element to write your text table. ex: text_elm
Hope it can help u,
Regards,
Oki
‎2009 Jul 23 3:59 PM
I tried to do this, but the program where i define the perform where i recover the text is not the same as the program where i call the sapscript because this is a standard program, so i needed to create a new program, and it doesn't work, because if you put write form SAP doesn't know what is the sapscript and it do anything.
Thanks anyway.
‎2009 Jul 23 4:13 PM
Perhaps a weird proposal:
call a subroutine in SAPSPRICT then you don't have to modify the SAP Standard. The subroutine can be in any report you like.
In the subroutine you might read the original text and you can eliminate the lines you don't like to put onto the form.
Store this text in a new standard text you create within your subroutine (perhaps something which includes the lot number, date and time in its key).
Then you return the key of the new text to the sapscript.
Afterwards you can include the the new standard text.
The call of subroutines is designed to do something which in the print program hasn't been included....
I didn't test to be frank. Perhaps there might be a problem with "commit work" .
kind regards
Herbert
‎2009 Jul 24 7:16 AM