‎2007 Apr 16 2:54 PM
Hello Friends,
I have developed a script and the driver program.
In my driver program I have all the data in my internal table and also am getting into the header line before passing to the script layout. I have activated my debugger for script.
The problem is the data is not passed from the program to script and I dont see any data in the script in the debugging mode, nor its printing.
I am triggering the driver program from IW32 Transaction.
Below is the driver program,
Please let me know what the problem is?
Ster.
REPORT zir00002 MESSAGE-ID zz.
TABLES:caufv, afpo, ihpa, lfa1, makt, mara, nast, caufvd.
DATA : t_caufv LIKE caufv OCCURS 0 WITH HEADER LINE,
t_afpo LIKE afpo OCCURS 0 WITH HEADER LINE,
t_ihpa LIKE ihpa OCCURS 0 WITH HEADER LINE,
t_lfa1 LIKE lfa1 OCCURS 0 WITH HEADER LINE,
t_makt LIKE makt OCCURS 0 WITH HEADER LINE,
t_mara LIKE mara OCCURS 0 WITH HEADER LINE,
t_resb LIKE resbd OCCURS 0 WITH HEADER LINE,
t_afvg LIKE afvgd OCCURS 0 WITH HEADER LINE,
t_usr03 LIKE usr03 OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF itab OCCURS 0,
lifnr TYPE lfa1-lifnr,
objnr LIKE caufv-objnr,
END OF itab.
DATA : shipto(50) TYPE c.
*selection-screen.
*PARAMETERS: p_aufnr LIKE caufv-aufnr.
----
Form ENTRY
----
Called from the output control program
----
FORM entry." USING return_code LIKE sy-subrc.
*START-OF-SELECTION.
PERFORM get_data.
*END-OF-SELECTION.
PERFORM sapscript.
ENDFORM. "ENTRY
&----
*& Form get_data
&----
text
----
--> p1 text
<-- p2 text
----
FORM get_data .
SELECT *
FROM caufv
INTO TABLE t_caufv
WHERE aufnr = caufvd-aufnr
WHERE aufnr = p_aufnr
AND ( auart = 'M04X' OR auart = 'M04I' ).
IF NOT t_caufv[] IS INITIAL.
SELECT *
FROM usr03
INTO TABLE t_usr03
FOR ALL ENTRIES IN t_caufv
WHERE bname = t_caufv-ernam.
SELECT *
FROM afpo
INTO TABLE t_afpo
FOR ALL ENTRIES IN t_caufv
WHERE aufnr = t_caufv-aufnr.
IF NOT t_afpo[] IS INITIAL.
SELECT *
FROM makt
INTO TABLE t_makt
FOR ALL ENTRIES IN t_afpo
WHERE matnr = t_afpo-matnr
AND spras = 'EN'. "redo
SELECT *
FROM mara
INTO TABLE t_mara
FOR ALL ENTRIES IN t_afpo
WHERE matnr = t_afpo-matnr
AND ( profl = 'HTV' OR profl = 'HZD'
OR profl = 'TV' OR profl = '' ).
ENDIF.
SELECT *
FROM ihpa
INTO TABLE t_ihpa
FOR ALL ENTRIES IN t_caufv
WHERE objnr = t_caufv-objnr
AND parvw = 'LF'.
IF NOT t_ihpa[] IS INITIAL.
LOOP AT t_ihpa.
IF t_ihpa-parnr+10(2) = space.
MOVE t_ihpa-parnr TO itab-lifnr.
MOVE t_ihpa-objnr TO itab-objnr.
ELSE.
MOVE t_ihpa-parnr+2(10) TO itab-lifnr.
MOVE t_ihpa-objnr TO itab-objnr.
ENDIF.
APPEND itab.
CLEAR : t_ihpa, itab.
ENDLOOP.
SELECT *
FROM lfa1
INTO TABLE t_lfa1
FOR ALL ENTRIES IN itab
WHERE lifnr = itab-lifnr.
ENDIF.
ENDIF.
ENDFORM. " get_data
&----
*& Form sapscript
&----
text
----
--> p1 text
<-- p2 text
----
FORM sapscript .
CALL FUNCTION 'OPEN_FORM'
EXPORTING
device = 'QK14'
dialog = ' '
form = 'ZIR00002Z_PM_WO1'
language = sy-langu.
LOOP AT t_caufv.
READ TABLE t_usr03 WITH KEY bname = t_caufv-ernam.
READ TABLE t_ihpa WITH KEY objnr = t_caufv-objnr.
READ TABLE itab WITH KEY objnr = t_ihpa-objnr.
READ TABLE t_lfa1 WITH KEY lifnr = itab-lifnr.
CONCATENATE t_lfa1-ort01 ',' t_lfa1-regio t_lfa1-pstlz
INTO shipto SEPARATED BY space .
CALL FUNCTION 'START_FORM'
EXPORTING
form = 'ZIR00002Z_PM_WO1'
language = sy-langu
startpage = 'PAGE1'.
LOOP AT t_afpo WHERE aufnr = t_caufv-aufnr.
READ TABLE t_makt WITH KEY matnr = t_afpo-matnr.
READ TABLE t_mara WITH KEY matnr = t_afpo-matnr.
CHECK sy-subrc = 0.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'BODY'
function = 'SET'
type = 'BODY'
window = 'MAIN'.
ENDLOOP.
CLEAR : t_afpo, t_makt, t_mara.
CALL FUNCTION 'END_FORM'.
ENDLOOP.
CLEAR: t_caufv, t_usr03, t_ihpa, itab, t_lfa1, shipto.
CALL FUNCTION 'CLOSE_FORM'.
ENDFORM. " sapscript
‎2007 Apr 16 4:09 PM
Hi!
If you don't want to copy the original ones, you might check out the WRITE_FORM:
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'BODY'
function = 'SET'
type = 'BODY'
window = 'MAIN'.
It is using an element called "BODY". Are you sure is there a BODY element in your SAPScript also?
Elements in the SAPScripts seems like this:
/E BODY
I've checked out, in the PM_COMMON sapscript there is an element like this:
/E TITLE_PAGE
Regards
Tamá
‎2007 Apr 16 3:07 PM
‎2007 Apr 16 3:15 PM
Hi,
CALL FUNCTION 'OPEN_FORM'
EXPORTING
device = 'QK14'
dialog = ' '
form = 'ZIR00002Z_PM_WO1'
language = sy-langu.
LOOP AT t_caufv.
READ TABLE t_usr03 WITH KEY bname = t_caufv-ernam.
READ TABLE t_ihpa WITH KEY objnr = t_caufv-objnr.
READ TABLE itab WITH KEY objnr = t_ihpa-objnr.
READ TABLE t_lfa1 WITH KEY lifnr = itab-lifnr.
CONCATENATE t_lfa1-ort01 ',' t_lfa1-regio t_lfa1-pstlz
INTO shipto SEPARATED BY space .
CALL FUNCTION 'START_FORM' " --> Write outside of the loop
EXPORTING
form = 'ZIR00002Z_PM_WO1'
language = sy-langu
startpage = 'PAGE1'.
LOOP AT t_afpo WHERE aufnr = t_caufv-aufnr.
READ TABLE t_makt WITH KEY matnr = t_afpo-matnr.
READ TABLE t_mara WITH KEY matnr = t_afpo-matnr.
CHECK sy-subrc = 0.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'BODY'
function = 'SET'
type = 'BODY'
window = 'MAIN'.
ENDLOOP.
CLEAR : t_afpo, t_makt, t_mara.
CALL FUNCTION 'END_FORM'.
ENDLOOP.
CLEAR: t_caufv, t_usr03, t_ihpa, itab, t_lfa1, shipto.
CALL FUNCTION 'CLOSE_FORM'.
ENDFORM. " sapscript
only put the WRITE_FORM with in the loop. and try
Regards
Sudheer
‎2007 Apr 16 3:26 PM
Thanks Sudheer.
I have tried it out but dosent work.
Any more suggestions.
Ster.
‎2007 Apr 16 3:32 PM
Hi,
Do not write the Start_form with in the loop and
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'BODY'
* function = 'SET' " --> Comment
* type = 'BODY' " --> Comment
window = 'MAIN'.
‎2007 Apr 16 3:49 PM
‎2007 Apr 16 4:04 PM
Hi!
I've also developed in the transaction IW32 some printer programs, but I've copied the standard printers programs and SAPScripts to a Z-one.
The original printer programs were: RIPRAT00 (->ZRIPRAT00), RIPRJT00 (->ZRIPRJT00), RIPRTT00 (->ZRIPRJT00).
And the original SAPScript is the PM_COMMON (->ZPM_COMMON).
Just comment out the unneccessery parts, correct the customizing and everything works fine.
Regards
Tamá
‎2007 Apr 16 3:37 PM
In your script are you accessing the correct globals??? Your program only populates the globals prefixed with t_ so only these will be populated in your script.
Although you have a TABLES statement you are not populating any of those work areas (TABLES:caufv, afpo, ihpa, lfa1, makt, mara, nast, caufvd).
Hope it helps.
‎2007 Apr 16 4:09 PM
Hi!
If you don't want to copy the original ones, you might check out the WRITE_FORM:
CALL FUNCTION 'WRITE_FORM'
EXPORTING
element = 'BODY'
function = 'SET'
type = 'BODY'
window = 'MAIN'.
It is using an element called "BODY". Are you sure is there a BODY element in your SAPScript also?
Elements in the SAPScripts seems like this:
/E BODY
I've checked out, in the PM_COMMON sapscript there is an element like this:
/E TITLE_PAGE
Regards
Tamá
‎2007 Apr 16 5:04 PM
Thanks Thamas,
I have developed a new script and a new driver program.
All the data that I need to print in my layout is as per the print program that I have written.
Also I have the body as my text element in my Script.
Any suggestions.
Ster.