2006 Feb 16 3:31 AM
Hi, i would like to know how do i display all the text (which may consist of more than 1 line) that i have extracted using a READ_TEXT FM in my print program? Once the text has been extracted and displayed, i would like the proceeding lines of text (if there are more than 1 line) to begin at a certain margin (i have defined a paragraph format as 6.2cm in tab option).
Have a look at the part of the print program that has the READ_TEXT FM statements which is going to extract the text from the PR Document header:
LOOP AT ITAB.
CLEAR: PR_TXT, PR_TXT[].
L_NAME = ITAB-BANFN.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = 'B01'
LANGUAGE = SY-LANGU
NAME = L_NAME
OBJECT = 'EBANH'
ARCHIVE_HANDLE = 0
* LOCAL_CAT =
TABLES
LINES = PR_TXT
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
LOOP AT PR_TXT.
MOVE: ITAB-BANFN TO PTXT_TAB-BANFN,
SY-TABIX TO PTXT_TAB-POSNR,
PR_TXT-TDLINE TO PTXT_TAB-LINE.
APPEND PTXT_TAB.
ENDLOOP.
As for my SAPSCRIPT, i did the following:
* Purchase Request Header : &PTXT_TAB-LINE(C)&
I would like all of the proceeding lines of text to appear at the same margin as when the first line of &PTXT_TAB-LINE& started (which i have found out is 6.2cm, so i created a tab called HT for this)
Message was edited by: Bernard Loh
2006 Feb 16 3:38 AM
Define a paragraph format for the text:
And make the settings in LEFT MARGIN 6.2 CM in the standard tab and assign this paragraph font to this text
P1 Purchase Request Header : &PTXT_TAB-LINE(C)&
---where P1 is your paragraph format.
2006 Feb 16 4:12 AM
Hi G,
i did as you said but i only wanted the next lines of &PTXT_TAB-LINE& to start displaying at the 6.2cm margin...now even the text "Purchase Request Header: " text is also appearing at that margin.
2006 Feb 16 4:18 AM
Hi Bernard,
Then you must set the tabs to 6.2 CM.
Set the tab setting in the paragraph format.
And display as :
Purchase Request Header : ,, &PTXT_TAB-LINE&
Else,
create a new window other than the one to display static text (Purchase Request Header : ) and position the new window accordingly.
Message was edited by: Wenceslaus G
2006 Feb 16 4:31 AM
2006 Feb 16 3:48 AM
REPORT ZZZZANC9 .
tables mara.
data: i_mara like mara occurs 0 with header line.
select matnr from mara
up to 100 rows
into corresponding fields of table i_mara
where matnr ne space.
CALL FUNCTION 'OPEN_FORM'
EXPORTING
APPLICATION = 'TX'
ARCHIVE_INDEX =
ARCHIVE_PARAMS =
DEVICE = 'PRINTER'
DIALOG = 'X'
FORM = 'ZZZZANC1'
LANGUAGE = SY-LANGU
OPTIONS =
MAIL_SENDER =
MAIL_RECIPIENT =
MAIL_APPL_OBJECT =
RAW_DATA_INTERFACE = '*'
IMPORTING
LANGUAGE =
NEW_ARCHIVE_PARAMS =
RESULT =
EXCEPTIONS
CANCELED = 1
DEVICE = 2
FORM = 3
OPTIONS = 4
UNCLOSED = 5
MAIL_OPTIONS = 6
ARCHIVE_ERROR = 7
INVALID_FAX_NUMBER = 8
MORE_PARAMS_NEEDED_IN_BATCH = 9
SPOOL_ERROR = 10
OTHERS = 11.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop at i_mara.
mara-matnr = i_mara-matnr.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'MATERIAL'
FUNCTION = 'SET'
TYPE = 'BODY'
WINDOW = 'MAIN'
IMPORTING
PENDING_LINES =
EXCEPTIONS
ELEMENT = 1
FUNCTION = 2
TYPE = 3
UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
SPOOL_ERROR = 8
OTHERS = 9
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endloop.
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT =
RDI_RESULT =
TABLES
OTFDATA =
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SEND_ERROR = 3
SPOOL_ERROR = 4
OTHERS = 5
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Look through above code. Sapscript should contain a text element (/E control) as below
/E MATERIAL
&mara-matnr&
2006 Feb 16 3:51 AM
Just to add to the previous post, this is how it works...
A text element declared in SAPscript can be specifically called from ABAP using the 'write_form' function module. So in your case you can loop at the internal table PTXT_TAB and call the write_form function. Make sure that you create a command with '/E' control in the SAPScript.
2006 Feb 16 4:19 AM
Hi Anand, does it mean that in my loop of the internal table for the WRITE_FORM FM, i should also place the FM for READ_TEXT within that same loop?
2006 Feb 16 4:40 AM
Nope. Heres the flow... (the location of open form can be different based on requirement and SAPscript structure).
fetch data (PRs).
loop at each PR.
Read text for PR.
open form.
<b>loop at text.
write text to text element.
endloop.</b>
Send any other data as required.
close form.
2006 Feb 16 4:50 AM
The FM is called at the 'Read text for PR' line below.
The idea is to get all required text lines in an internal table, loop at that internal table and then fire 'write_form' function modules. The text lines will appear one after another in the SAPscript.
2006 Feb 16 4:59 AM
Is this what you meant?
CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM = 'ZLPUPR005'
EXCEPTIONS
CANCELED = 1.
LOOP AT ITAB.
LOOP AT PR_TXT.
MOVE: ITAB-BANFN TO PTXT_TAB-BANFN,
SY-TABIX TO PTXT_TAB-POSNR,
PR_TXT-TDLINE TO PTXT_TAB-LINE.
APPEND PTXT_TAB.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ITEM_LINE'
WINDOW = 'MAIN'
EXCEPTIONS
ELEMENT = 1.
ENDLOOP.
ENDLOOP.
CALL FUNCTION 'CLOSE_FORM'
EXCEPTIONS
UNOPENED = 1.
my READ_TEXT FM is currently just before the OPEN_FORM FM. As of now, the output that is managed to display is only the first line of the text that was extract. The PR text that i am testing has 3 lines, the later 2 won't seem to appear
2006 Feb 16 5:09 AM
Bernard,
The append on PTXT_TAB is not required as SAPScript is only looking at the header.
But I am at a loss to understand why you are seeing only one line in the output. Should be 3 as you said. In debug mode, were you able to see 3 lines in internal table PR_TXT? Can you also show text element 'ITEM_LINE'?
2006 Feb 16 5:56 AM
Thanks Anand for your reply.
When i looked at PR_TXT in debug mode, all the 3 lines do appear and looks something like this:
TDFORMAT | TDLINE
---------------------------------------------------------------------------
* |TESTING PR HEADER testing of several lines of text.......123123
|.....456456456 456456 456456 456456 456465 45656 45646546465 4564
|45646546546546 456456464 grs
Perhaps its the looping?
What do you mean by showing the text element 'ITEM_LINE'?
2006 Feb 16 6:03 AM
'ITEM_LINE' should be declared as text element in the SAPscript, just like Material in the example I gave. Can you show the lines from the Sapscript; it should look something like this
/E ITEM_LINE
Purchase Request Header : &PTXT_TAB-LINE(C)&
2006 Feb 16 6:10 AM
Oh, actually i wrote the /E ITEM_LINE at the beginning of my sapscript. Because all my other variables which i want to display all comes from the same table. Should i have defined another Text Element for the PR Header text?
2006 Feb 16 6:18 AM
Not necessary. Please declare it only for the the ones you want to trigger by write_form. The ones you always want to appear like PR header text need not be declared in a text element.
2006 Feb 16 6:20 AM
Not necessary. Please declare it only for the the ones you want to trigger by write_form. The ones you always want to appear like PR header text need not be declared in a text element.
2006 Feb 16 7:03 AM
What am i actually doing wrong?
Is it the SAPSCRIPT side or the print program itself?
2006 Feb 16 7:49 AM
Try doing something like this...
say t_text is ur int table having the text ( 4 lines suppose).
in ur sapscript..write ur first line as u r currently doing but with a variable(g_text) conating first line of text.
ie, xxxxxxxxxxxxxxx : g_text
<b>/E TEXTS</b> " text element for texts, to be looped
P1 T_TEXT
IN UR PROGRAM ,
READ T_TEXT INDEX 1 INTO G_TEXT.
LOOP AT T_TEXT.
IF SY-TABIX <> 1.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'TEXT'
ENDIF.
ENDLOOP.
tHIS SHUD WORK FOR U....
Regards,
Bikash
2006 Feb 16 7:54 AM
Please read through the documentation on text elements for more information on how they work. That will help clear your conceptual doubts.
2006 Feb 16 6:12 AM
Hi,
There is indeed another way to print the text. Instead of looping and sending the data one line after the other by calling an element. This can be a performance bottleneck. There can be another approach.
Within the SAPSCRIPT try to call an INCLUDE program and pass the necessary data to it.
eg: PERFORM GET_TEXT IN PROGRAM Z_SD_GET_TEXT
using &NAME& &OBJECT&
changing &TEXT1& &TEXT2& &TEXT3&
you have to create a program Z_SD_GET_TEXT where-in u need to write the function module 'READ TEXT' with the parameters passed from the SAPSCRIPT.
Process the internal table and pass the text1,text2,text3 accordingly from the program back to SAPSCRIPT, where u print all the text at one go.
But there is a constraint to this approach, here the length of characters need to be predetermined. Say the requirement is print MAX. of 500 characters of the text. Then you can distribute that accordingly by how many variables u need to create.
Regards,
Anirban