Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

"Write_Form" function module is not working

Former Member
0 Likes
2,628

Dear Experts,

I'm in the midst of customizing the sapscript form.

I've added the following lines in include (Z_RFFORI06) of print medium program Z_RFFOAVIS_FPAYM.

IF hlp_xhrfo EQ space.

        CALL FUNCTION 'WRITE_FORM'

           EXPORTING

            window   = 'main_or'

            element  = '699'

            function = 'APPEND'

          EXCEPTIONS

            window   = 1

            element  = 2.

ENDIF.

I also added the following lines in the sapscript form

/E          699

/*          -------------------- print invoice line item -------------------------------------------------

/:          IF &REGUH-LIFNR& EQ ' '

T2        &BSEG-REBZG&,,&VBRK-FKDAT&,,&VBRK-NETWR&,,&BSEG-NEBTR&

/:          ENDIF

I used debugger to test print and the system did run the function module "write_form" but nothing came out on the printout.

I've even tried to use Write statement, and it printed out to the display, that means, there were values in the variables.

Does anyone has any idea?

regards,

Abraham

1 ACCEPTED SOLUTION
Read only

che_eky
Active Contributor
0 Likes
2,380

Another thing, comment out the IF check in the window 699 and put it back once the text is printing. This will make testing easier:

IF &REGUH-LIFNR& EQ ' '

You may need to change the above to IF &REGUH-LIFNR& EQ '           '.

But just comment it out for now.

16 REPLIES 16
Read only

che_eky
Active Contributor
0 Likes
2,380

Try changing the window = 'main_or' to uppercase window = 'MAIN_OR'

        CALL FUNCTION 'WRITE_FORM'

           EXPORTING

            window   = 'main_or'

            element  = '699'

            function = 'APPEND'

          EXCEPTIONS

            window   = 1

            element  = 2.

Assuming there is a window called MAIN_OR in the sap script and a text element 699.

Read only

che_eky
Active Contributor
0 Likes
2,381

Another thing, comment out the IF check in the window 699 and put it back once the text is printing. This will make testing easier:

IF &REGUH-LIFNR& EQ ' '

You may need to change the above to IF &REGUH-LIFNR& EQ '           '.

But just comment it out for now.

Read only

Former Member
0 Likes
2,380
Hi guys,
thanks for your help..
I changed the window's name, 'main_or' to big capital letter, 'MAIN_OR', and it printed out but only the last line of the internal table.
I'm not sure whether they actually process the content in the 'MAIN_OR' window.
The following are the lines I added in Z_RFFORI06.
LOOP AT it_bseg.
  AT FIRST.
  bseg-zuonr = it_bseg-zuonr.   
  ENDAT.
bseg-rebzg = it_bseg-rebzg.   
bseg-nebtr = it_bseg-nebtr.  
WRITE:/ bseg-rebzg, bseg-nebtr.
   IF hlp_xhrfo EQ space.
        CALL FUNCTION 'WRITE_FORM'
           EXPORTING
            window   = 'MAIN_OR'
            element  = '699'
            function = 'APPEND'
          EXCEPTIONS
            window   = 1
            element  = 2.
   ENDIF.
ENDLOOP.
As you can see the above variables, 'bseg-rebzg' and 'bseg-nebtr' were printed repeatedly for 4 times as there're 4 rows in the internal table it_bseg.
The WRITE statement works fine.
What else did I miss out?
regards,
Abraham
Read only

0 Likes
2,380

Hi Chaun,

Keep all in caps.SAP is not a case sensitive but space sensitive.Even though keep in caps.

Regards,

Madhu.

Read only

Former Member
0 Likes
2,380

It's still the same after I made them to big cap.

Anyway, I added CLEAR statement immediately after the ENDLOOP, in order to clear the value in the above mentioned variables, and it printed out 4 lines of zero amount.

It seems like that the system pick up the last values that remained in the variables, and since it's reset after end of WRITE_FORM by the CLEAR statement, it has no values to print.

Does anyone know how exactly the system push the values to the print layout before sent for printing?

regards,

Abraham

Read only

Former Member
0 Likes
2,380

Hi ,

Can i check with you window main is calling some condition if hlp_xhrfo EQ space .

Check for this condition may be for some record condition is getting truncate .

Check in Debugging .

Regards,

Yukti

Read only

Former Member
0 Likes
2,380

Hi Yukti,

I've removed "if hlp_xhrfo EQ space" but still the same.

I've tried with Debugger and it showed there's correct values in the variables each loop before it move to the 'WRITE_FORM' function module, same as what was displayed by WRITE statement.  

May I know where else other than WRITE_FORM function module, does the system process the print layout?

regards,

Abraham

Read only

Former Member
0 Likes
2,380
Hi guys,
The following is the print out.
1800000283   150.00
1800000283   150.00
1800000283   150.00
1800000283   150.00
As mentioned earlier, the WRITE_FORM did print out but only the last line of the internal table repeatedly for 4 times (exactly the number of loops occurred).
It supposed print the first line and followed by subsequent lines of the internal table.
Does anyone here has any idea?
regards,
Abraham
Read only

che_eky
Active Contributor
0 Likes
2,380

Where have you declared BSEG? is it declared globally or locally? It must be declared globally for it to be visible in the sap script. The write statement maybe referring to a local declaration of BSEG.

Show us where you have declared BSEG and if possible give us more from Z_RFFORI06 and Z_RFFOAVIS_FPAYM.

Che

Read only

Former Member
0 Likes
2,380

Hi Che,

I declared BSEG in Z_RFFORI00 as following.

tables:

  bseg.                               "Accounting Document Segment

and internal table in Z_RFFORI06 as following.

FORM avis_schreiben.


  DATA:

   

    it_bseg             TYPE TABLE OF bseg WITH HEADER LINE.  

    

The way I look at the issue, it seems like the declaration has no problem as print medium program could print out except that it's print the last line repeatedly only.

I did use the Debugger, and it showed the values were carried in until just before WRITE_FORM, but once entered, it dissappeared, but will come back again once exit from WRITE_FORM.

Would that be caused by the declaration?

regards,

Abraham

Read only

che_eky
Active Contributor
0 Likes
2,380

Hi Abraham,

From what I have seen you cannot print table data in a non main window. You are printing the contents of table IT_BSEG in window MAIN_OR, is it a Main window or a Secondary window? The results you are getting are consistent with printing in a secondary window i.e. only the last line of data printed is shown.

Take a look at this thread:

//http://scn.sap.com/thread/1059966

Che

Read only

Former Member
0 Likes
2,380

Hi Che,

At last my friend, you make my day.. It works now!.. just because of one little setting.. I moved the text element and the variables to the 'MAIN' window.

Thanks once again..

regards,

Abraham

Read only

Former Member
0 Likes
2,380

I think

            window   = 'main_or'

should be written 'MAIN'_OR', too.

If this is not the problem check the window has exact the same name.

Read only

former_member212705
Active Participant
0 Likes
2,380

Hi Abraham,

Change your window name from lowercase to upper case then try

CALL FUNCTION 'WRITE_FORM' 

           EXPORTING

            window   = 'MAIN_OR'

i think now it should work.

Regards,

Ashish

Read only

0 Likes
2,380

Hi Ashish,

I already done that earlier and it worked but didn't print out exactly the values being passed to.

Now it's printing the last line's value only for 4 times repeatedly as there're 4 rows of data in the internal table. 

Do you have any idea?

regards,

Abraham

Read only

0 Likes
2,380

Hi Abraham,

Clear the variables just before 'ENDLOOP', then check.

Regards,

Ashish