Application Development 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: 

creating different spool requests based on sorting -part II

Former Member
0 Kudos
408

hi folks,

Now I have added the group field to 'accitab' and as mentioned I have another itable (same as 'accitab') called 'final_accitab where I have the recrods for all the customers and their corresponding group types too.

something like this..

customernumber ........ sortgroup

1000001 1

1000001 1

1000001 1

1000012 1

1000012 1

1000112 1

.

.

.

.

10000002 2

10000002 2

10000002 2

.

.

.

.

10000003 3 and so on

Now I have to print the customers based on the sorting therefore I should be passing the records of all the customers that come under a common sort type into one spool request,( I think that way!!) and how to do that ?

ii)how to print separate statements for each customer

for the same sort within the same spool request.

Thanks in advance

Vinu

43 REPLIES 43

Former Member
0 Kudos
61

you have to open your sapscript or your smartform every time you have to create a new spool.

So, if I remember well you use a smartform, you shoUld use the function to open and close smartform to part from smartforms:

DATA: E_SSFCOMPIN TYPE SSFCOMPIN,

SORT LIKE FINAL_ACCITAB-SORTGROUP,

FL_OPEN,

T_CUSTOMER LIKE STANDARD TABLE OF FINAL_ACCITAB.

LOOP AT FINAL_ACCITAB.

  • Create a new spool while sortgroup is changing

IF FINAL_ACCITAB-SORTGROUP <> SORT.

SORT = FINAL_ACCITAB-SORTGROUP.

  • Before you close previous print (smartform and spool)

IF FL_OPEN = 'X'.

CALL FUNCTION 'SSF_CLOSE'.

ENDIF.

CALL FUNCTION 'SSF_OPEN'

EXPORTING

INPUT = E_SSFCOMPIN

EXCEPTIONS

ERROR = 1

OTHERS = 2.

IF SY-SUBRC = 0. FL_OPEN = 'X'. ENDIF.

ENDIF.

  • Print data while customer is changing

AT NEW CUSTOMER.

IF NOT T_CUSTOMER[] IS INITIAL.

CALL FUNCTION FM_NAME_OF_SMART

.......

TABLES

CUSTOMER = T_CUSTOMER.

  • After printing data, clear the customer table

REFRESH T_CUSTOMER.

ENDIF.

ENDAT.

  • Append records of the same customer

INSERT FINAL_ACCITAB INTO TABLE T_CUSTOMER.

ENDLOOP.

IF SY-SUBRC = 0.

  • Print data of last customer

IF NOT T_CUSTOMER[] IS INITIAL.

CALL FUNCTION FM_NAME_OF_SMART

.......

TABLES

CUSTOMER = T_CUSTOMER.

CALL FUNCTION 'SSF_CLOSE'.

  • After printing data, clear the customer table

REFRESH T_CUSTOMER.

ENDIF.

ENDIF.

0 Kudos
61

hi folks,

Max happen to share this piece of information here.

Thanks a lot for the help. But I am finding hard to incorporate thsi piece into my code

I am not able to understand that 'CUSTOMER' he has used and

I am getting an error at 'AT NEW CUSTOMER'

The function module that I have declared for the smartform goes like this...

Can ANY ONE OF you help me understand THIS piece of code w.r.t the function module I am using?

  • now call the generated function module

call function fm_name

exporting

  • archive_index =

  • archive_parameters =

  • control_parameters = control

  • mail_appl_obj =

  • mail_recipient =

  • mail_sender =

  • output_options = output_options

  • user_settings = 'X'

ZTOTAL = ZTOTALAMOUNT

zscan_code = scan_number

  • zpartner = bpartner

z_bdate = e_date

zadnumber = adnumber

zadnumber1 = zzadnumber

zagencynumber = agencynumber

z_payment_terms = v_payment_terms

zzadname = adname1

zadname = adname

zagencyname = agencyname

zphone = bphone

zcreditgroup = zcredittext

z_bperiod = monthn

ztotalcredits = zappliedcredits1

ztotalbalance = zcurrenttotal

ZZEXTZIP = zzextensionzip

  • bookings = bookings

  • importing document_output_info =

  • job_output_info =

  • job_output_options =

tables

stribunecustomer = customer

accountdata = T_CUSTOMER

zcdatar = zcdata

zaging = agingdataitab

ZADDRESS = i_address_number

exceptions formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

others = 5.

Thanks for your help..

VINU

0 Kudos
61

The customer should be the name of field where customer number is stored, I don't know how you have called it.

0 Kudos
61

thanks Max,

I have to declare the export parameter 'INPUT = E_SSFCOMPIN' IN THE SMARTFORM.

Can you elaborate as how to declare them in the smartform?

Vinu

0 Kudos
61

Hi Max,

I have added your peice of code in this way...

ERROR** tHE parameter 'INPUT' has not been defined.

Just take a llok into my code and can you help me through here?

Thanks

call function 'SSF_FUNCTION_MODULE_NAME'

exporting formname = p_form

  • variant = ' '

  • direct_call = ' '

importing fm_name = fm_name

exceptions no_form = 1

no_function_module = 2

others = 3.

if sy-subrc <> 0.

  • error handling

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

exit.

endif.

DATA:E_SSFCOMPIN TYPE SSFCOMPIN,

SORT LIKE FINAL_ACCITAB-ZSORTGROUP,

FL_OPEN,

T_CUSTOMER LIKE STANDARD TABLE OF FINAL_ACCITAB.

LOOP AT FINAL_ACCITAB.

IF FINAL_ACCITAB-ZSORTGROUP <> SORT.

SORT = FINAL_ACCITAB-ZSORTGROUP.

IF FL_OPEN = 'X'.

CALL FUNCTION 'SSF_CLOSE'.

ENDIF.

CALL FUNCTION 'SSF_OPEN'

EXPORTING

INPUT = E_SSFCOMPIN

EXCEPTIONS

ERROR = 1

OTHERS = 2.

IF SY-SUBRC = 0. FL_OPEN = 'X'.

ENDIF.

ENDIF.

AT NEW zadvertiser.

IF NOT T_CUSTOMER[] IS INITIAL.

  • now call the generated function module

call function fm_name

exporting

  • archive_index =

  • archive_parameters =

  • control_parameters = control

  • mail_appl_obj =

  • mail_recipient =

  • mail_sender =

  • output_options = output_options

  • user_settings = 'X'

ZTOTAL = ZTOTALAMOUNT

zscan_code = scan_number

  • zpartner = bpartner

z_bdate = e_date

zadnumber = adnumber

zadnumber1 = zzadnumber

zagencynumber = agencynumber

z_payment_terms = v_payment_terms

zzadname = adname1

zadname = adname

zagencyname = agencyname

zphone = bphone

zcreditgroup = zcredittext

z_bperiod = monthn

ztotalcredits = zappliedcredits1

ztotalbalance = zcurrenttotal

ZZEXTZIP = zzextensionzip

  • bookings = bookings

  • importing document_output_info =

  • job_output_info =

  • job_output_options =

tables

stribunecustomer = customer

accountdata = T_CUSTOMER

zcdatar = zcdata

zaging = agingdataitab

ZADDRESS = i_address_number

exceptions formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

others = 5.

REFRESH T_CUSTOMER.

ENDIF.

ENDAT.

INSERT FINAL_ACCITAB INTO TABLE T_CUSTOMER.

ENDLOOP.

IF SY-SUBRC = 0.

  • Print data of last customer

IF NOT T_CUSTOMER[] IS INITIAL.

call function fm_name

exporting

  • archive_index =

  • archive_parameters =

  • control_parameters = control

  • mail_appl_obj =

  • mail_recipient =

  • mail_sender =

  • output_options = output_options

  • user_settings = 'X'

ZTOTAL = ZTOTALAMOUNT

zscan_code = scan_number

  • zpartner = bpartner

z_bdate = e_date

zadnumber = adnumber

zadnumber1 = zzadnumber

zagencynumber = agencynumber

z_payment_terms = v_payment_terms

zzadname = adname1

zadname = adname

zagencyname = agencyname

zphone = bphone

zcreditgroup = zcredittext

z_bperiod = monthn

ztotalcredits = zappliedcredits1

ztotalbalance = zcurrenttotal

ZZEXTZIP = zzextensionzip

  • bookings = bookings

  • importing document_output_info =

  • job_output_info =

  • job_output_options =

tables

stribunecustomer = customer

accountdata = T_CUSTOMER

zcdatar = zcdata

zaging = agingdataitab

ZADDRESS = i_address_number

exceptions formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

others = 5.

CALL FUNCTION 'SSF_CLOSE'.

  • After printing data, clear the customer table

REFRESH T_CUSTOMER.

ENDIF.

ENDIF.

if sy-subrc <> 0.

  • error handling

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif

0 Kudos
61

This code is extracted from my old program, but it should be good for you (I hope):

  • Open smartforms:

IF E_SSFCOMPIN IS INITIAL.

  • Get user data:

SELECT SINGLE * FROM USR01 INTO W_USR01 WHERE BNAME = SY-UNAME.

E_SSFCOMPIN-TDDEST = W_USR01-SPLD.

IF W_USR01-SPDB = 'G'.

E_SSFCOMPIN-TDIMMED = 'X'.

ENDIF.

E_SSFCOMPIN-TDNEWID = 'X'.

IF W_USR01-SPDA = 'D'.

E_SSFCOMPIN-TDDELETE = 'X'.

ENDIF.

  • Open dialog

E_SSFCOMPIN-DIALOG = 'X'.

ELSE.

  • Only first time it opens dialog

CLEAR E_SSFCOMPIN-DIALOG.

ENDIF.

CALL FUNCTION 'SSF_OPEN'

EXPORTING

INPUT = E_SSFCOMPIN

  • IMPORTING

  • RESULT = I_SSFCRESOP

EXCEPTIONS

ERROR = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

MESSAGE S012(SSFCOMPOSER).

STOP.

ENDIF.

........

  • CALL SMARTFORMS

DATA: SSFCTRLOP LIKE SSFCTRLOP.

  • Set this flag becouse you drive opening and closing

  • smartforms

SSFCTRLOP-NO_OPEN = 'X'.

SSFCTRLOP-NO_CLOSE = 'X'.

CALL FUNCTION FM_NAME

EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS = ARC_PARAMS

CONTROL_PARAMETERS = SSFCTRLOP

0 Kudos
61

I think it should works, try:

DATA:E_SSFCOMPIN TYPE SSFCOMPIN,

SORT LIKE FINAL_ACCITAB-ZSORTGROUP,

FL_OPEN,

T_CUSTOMER LIKE STANDARD TABLE OF FINAL_ACCITAB.

  • Fill structure E_SSFCOMPIN with print parameters, if

  • you don't know them open dialog:

  • You can get user parameters:

SELECT SINGLE * FROM USR01 INTO W_USR01 WHERE BNAME = SY-UNAME.

E_SSFCOMPIN-TDDEST = W_USR01-SPLD.

IF W_USR01-SPDB = 'G'.

E_SSFCOMPIN-TDIMMED = 'X'.

ENDIF.

E_SSFCOMPIN-TDNEWID = 'X'.

IF W_USR01-SPDA = 'D'.

E_SSFCOMPIN-TDDELETE = 'X'.

ENDIF.

  • Open dialog

E_SSFCOMPIN-DIALOG = 'X'.

.

  • Block opening and closing in FM of smartforms

DATA: SSFCTRLOP LIKE SSFCTRLOP

SSFCTRLOP-NO_OPEN = 'X'.

SSFCTRLOP-NO_CLOSE = 'X'.

LOOP AT FINAL_ACCITAB.

IF FINAL_ACCITAB-ZSORTGROUP <> SORT.

SORT = FINAL_ACCITAB-ZSORTGROUP.

IF FL_OPEN = 'X'.

CALL FUNCTION 'SSF_CLOSE'.

ENDIF.

CALL FUNCTION 'SSF_OPEN'

EXPORTING

INPUT = E_SSFCOMPIN

EXCEPTIONS

ERROR = 1

OTHERS = 2.

IF SY-SUBRC = 0.

FL_OPEN = 'X'.

  • Only first time it opens dialog

CLEAR E_SSFCOMPIN-DIALOG.

ENDIF.

AT NEW ZADVERTISER.

IF NOT T_CUSTOMER[] IS INITIAL.

  • now call the generated function module

CALL FUNCTION FM_NAME

EXPORTING

  • archive_index =

  • archive_parameters =

control_parameters = SSFCTRLOP

  • mail_appl_obj =

  • mail_recipient =

  • mail_sender =

  • output_options = output_options

  • user_settings = 'X'

ZTOTAL = ZTOTALAMOUNT

ZSCAN_CODE = SCAN_NUMBER

  • zpartner = bpartner

Z_BDATE = E_DATE

ZADNUMBER = ADNUMBER

ZADNUMBER1 = ZZADNUMBER

ZAGENCYNUMBER = AGENCYNUMBER

Z_PAYMENT_TERMS = V_PAYMENT_TERMS

ZZADNAME = ADNAME1

ZADNAME = ADNAME

ZAGENCYNAME = AGENCYNAME

ZPHONE = BPHONE

ZCREDITGROUP = ZCREDITTEXT

Z_BPERIOD = MONTHN

ZTOTALCREDITS = ZAPPLIEDCREDITS1

ZTOTALBALANCE = ZCURRENTTOTAL

ZZEXTZIP = ZZEXTENSIONZIP

  • bookings = bookings

  • importing document_output_info =

  • job_output_info =

  • job_output_options =

TABLES

STRIBUNECUSTOMER = CUSTOMER

ACCOUNTDATA = T_CUSTOMER

ZCDATAR = ZCDATA

ZAGING = AGINGDATAITAB

ZADDRESS = I_ADDRESS_NUMBER

EXCEPTIONS FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

REFRESH T_CUSTOMER.

ENDIF.

ENDAT.

INSERT FINAL_ACCITAB INTO TABLE T_CUSTOMER.

ENDLOOP.

IF SY-SUBRC = 0.

  • Print data of last customer

IF NOT T_CUSTOMER[] IS INITIAL.

CALL FUNCTION FM_NAME

EXPORTING

  • archive_index =

  • archive_parameters =

  • control_parameters = control

  • mail_appl_obj =

  • mail_recipient =

  • mail_sender =

  • output_options = output_options

  • user_settings = 'X'

ZTOTAL = ZTOTALAMOUNT

ZSCAN_CODE = SCAN_NUMBER

  • zpartner = bpartner

Z_BDATE = E_DATE

ZADNUMBER = ADNUMBER

ZADNUMBER1 = ZZADNUMBER

ZAGENCYNUMBER = AGENCYNUMBER

Z_PAYMENT_TERMS = V_PAYMENT_TERMS

ZZADNAME = ADNAME1

ZADNAME = ADNAME

ZAGENCYNAME = AGENCYNAME

ZPHONE = BPHONE

ZCREDITGROUP = ZCREDITTEXT

Z_BPERIOD = MONTHN

ZTOTALCREDITS = ZAPPLIEDCREDITS1

ZTOTALBALANCE = ZCURRENTTOTAL

ZZEXTZIP = ZZEXTENSIONZIP

  • bookings = bookings

  • importing document_output_info =

  • job_output_info =

  • job_output_options =

TABLES

STRIBUNECUSTOMER = CUSTOMER

ACCOUNTDATA = T_CUSTOMER

ZCDATAR = ZCDATA

ZAGING = AGINGDATAITAB

ZADDRESS = I_ADDRESS_NUMBER

EXCEPTIONS FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

CALL FUNCTION 'SSF_CLOSE'.

  • After printing data, clear the customer table

REFRESH T_CUSTOMER.

ENDIF.

ENDIF.

IF SY-SUBRC <> 0.

  • error handling

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF

0 Kudos
61

Max, I did not understand the purpose of getting this user data. Can you just elaborate on that?

Thanks

0 Kudos
61

thanks Max I will go through it. I will getback and award full points once I get it right.

0 Kudos
61

Max, the error points to the function module 'SSF_OPEN' with the parameter 'INPUT' and this parameter is not found.

I need to enter the input parameters where should I be doing it?

Can you help me out here?

Thanks

0 Kudos
61

hi Max,

It is showing an runtime error saying that the parameter 'INPUT' is not defined.

I would appreciate your help in this regard.

thanks

Vinu

0 Kudos
61

I'm sorry but I wasn't conneted to the forum.

Anyway the problem depend on release which are you using.

My piece of code is extracted from a program in release 4.6C, in this release the function SSF_OPEN has a parameter called INPUT (as structure SSFCOMPIN), but I could see this function in rel. 4.7 and there isn't parameter INPUT but there is OUTPUT_OPTIONS as structure SSFCOMPOP.

So I believe you should use OUTPUT_OPTIONS instead of INPUT

0 Kudos
61

Thanks for your time,

Now, I am going through runtime analysis and in the dialog box, but when I check the 'Print' button it throws an error,

Handle not valid for open spool request.

The release 4.7 so I need to be using the structure SSFCOMPOP and it does not have the

E_SSFCOMPOP-DIALOG field, I commented it, For the version 4.7 is there any changes that I need to make in the code?

Can you help me on that?

Thanks in advance.

vinu

0 Kudos
61

You also mentioned to use print parameters like from the structure 'SSFCOMPOP'

'TDDEST' 'TDPRINTER', 'TDNEWID', 'TDIMMED', something like that... which print parameters to be used because they have not highlighted anything related to that in the requirement.

all they have asked is customers need to be grouped according to their sort type and directed into one spool request and within that spool request the statements for these customers have to be printed separately.

HOPE YOU CAN HELP ME THROUGH THIS ISSUE.

THANKS

VINU

0 Kudos
61

Check your code, I think you call FM for closing before printing something.

0 Kudos
61

Thanks Max,

the issue is in a far better shape.

Question: while looping through 'final_accitab' into 'T_Customers' I am gathering the data for each customer number separately through the

' INSERT FINAL_ACCITAB INTO TABLE T_CUSTOMER' within the 'function fm_name'

once the entire data is gathered for a customer it runs through the FM FM_name to REFRESH T_CUSTOMER AND IT DOES NOT PRINT ANY STATEMENTS AT THIS TIME BUT IT RUNS THROUGH THE LOOP AGAIN GATHERS DATA INTO T_CUSTOMER AND NOW IT PRINTS THE STATEMENT THAT HAS THE DATA OF BOTH THE CUSTOMERS IN ONE PAGE.

one more thing, in the fm module

ZADNUMBER = ADNUMBER

ZADNUMBER1 = ZZADNUMBER

ZADNAME = ADNAME

ZAGENCYNAME = AGENCYNAME

these values pick up the last record of the final_accitab i.e the last customer number.

It is one of the major issues I am working on, I would really appreciate if you could help me in this regard.

Thanks

Vinu.

0 Kudos
61

The print starts when the closing (FM SSF_CLOSE) is called.

The system should print as many documents as many calling of smartforms, and for every calling it should create a new page: check your smartform.

You can try to test this situation creating a case like this:

- Open smartform,

- Load customer table,

- Call smartform,

- Load customer table;

- Call smartform;

- Close smartform;

Save your data ADNUMBER,..... at end of loop or after inserting a record into T_CUSTOMER.

0 Kudos
61

hi Max,

The program code is throwing up a different error (I was not changed anything) now it is gathering the data based on the customer into 'T_customer' but is not printing any statement out here

It throws a cancel dialog box gives an error message :

'No output request open. End not possible'.

what does that mean?

I have not explored a lot in this area (generating spool requests) , henceforth seeking your help a lot. Thanks a lot for your help in advance.

Vinu

0 Kudos
61

i Vinu

You have that error becouse you close your print without printing something before.

I can't know how your smartform is, but I create an example in my system and I hope it can help you.

So I create a smartform ZTEST with only one page, after I create a control program that calls my smartform:

it open my smartform for 3 times (so I have 3 spool) and for every opening It calls my smartform for 4 times: so I have 4 prints in each spool.

DATA FM_NAME TYPE RS38L_FNAM.

DATA: SSFCTRLOP TYPE SSFCTRLOP,

SSFCTRLOP_OPEN TYPE SSFCTRLOP,

SSFCRESOP TYPE SSFCRESOP,

SSFCOMPOP TYPE SSFCOMPOP.

  • Get FM name

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

FORMNAME = 'ZTEST'

IMPORTING

FM_NAME = FM_NAME.

DO 3 TIMES.

IF NOT SSFCOMPOP IS INITIAL.

  • After first time dialog doesn't open

SSFCTRLOP_OPEN-NO_DIALOG = 'X'.

ENDIF.

CALL FUNCTION 'SSF_OPEN'

EXPORTING

USER_SETTINGS = SPACE

OUTPUT_OPTIONS = SSFCOMPOP

CONTROL_PARAMETERS = SSFCTRLOP_OPEN

IMPORTING

JOB_OUTPUT_OPTIONS = SSFCRESOP

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 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.

ELSE.

  • Get print parameter choosen in the first print and

  • transfer them for next call of fm SSF_OPEN

MOVE-CORRESPONDING SSFCRESOP TO SSFCOMPOP.

ENDIF.

  • Block open and close of smartform in FM

SSFCTRLOP-NO_OPEN = 'X'.

SSFCTRLOP-NO_CLOSE = 'X'.

DO 4 TIMES.

  • Print my document for three times

CALL FUNCTION FM_NAME

EXPORTING

CONTROL_PARAMETERS = SSFCTRLOP.

ENDDO.

  • Close

CALL FUNCTION 'SSF_CLOSE'.

ENDDO.

This example works fine: I run it.

I think your program should be organized as my example:

- Call fM SSF_OPEN everytime you want to create a new spool, but before you have to close the previous spool (SSF_CLOSE);

- Call FM of smartform as many time as prints which should be in a spool.

Max

Message was edited by: max bianchi

Message was edited by: max bianchi

0 Kudos
61

hi Max,

Thanks , I will be working on that,

in the code that you had given there was FL_OPEN and I did not understand what it was for? can you just elaborate on the purpose of using it?

thanks

Vinu

0 Kudos
61

Hi Vinu

In first time in which you call SSF_OPEN there shouldn't be any problem, but after you have to recall SSF_OPEN only if you have called SSF_CLOSE before.

So my idea was to use a flag (FL_OPEN) to check it, becouse I had placed the call of SSF_CLOSE before.

LOOP AT .......

IF FL_OPEN = 'X'.

  • If in the previous loops SSF_OPEN has been called,

  • now it has to close spool

CALL SSF_CLOSE

......

ENDIF.

  • After closing previous spool, it open another one:

CALL SSF_OPEN

IF SY-SUBRC = 0.

  • Set open flag to can call fm of close in a next loops

FL_OPEN = 'X'.

ENDIF.

Max

0 Kudos
61

Thanks Max for your paitence and help..

My updated code goes like this.... on the same lines as yours...

DATA:SSFCTRLOP TYPE SSFCTRLOP,

SSFCTRLOP_OPEN TYPE SSFCTRLOP,

SSFCRESOP TYPE SSFCRESOP,

E_SSFCOMPOP TYPE SSFCOMPOP,

SORT LIKE FINAL_ACCITAB-ZSORTGROUP,

FL_OPEN,

T_CUSTOMER LIKE STANDARD TABLE OF FINAL_ACCITAB.

call function 'SSF_FUNCTION_MODULE_NAME'

exporting formname = p_form

  • variant = ' '

  • direct_call = ' '

importing fm_name = fm_name

exceptions no_form = 1

no_function_module = 2

others = 3.

LOOP AT FINAL_ACCITAB.

IF FINAL_ACCITAB-ZSORTGROUP <> SORT.

SORT = FINAL_ACCITAB-ZSORTGROUP.

IF NOT E_SSFCOMPOP IS INITIAL.

  • After first time dialog doesn't open

SSFCTRLOP_OPEN-NO_DIALOG = 'X'.

ENDIF.

IF FL_OPEN = 'X'.

CALL FUNCTION 'SSF_CLOSE'.

ENDIF.

CALL FUNCTION 'SSF_OPEN'

EXPORTING

USER_SETTINGS = SPACE

OUTPUT_OPTIONS = E_SSFCOMPOP

CONTROL_PARAMETERS = SSFCTRLOP_OPEN

IMPORTING

JOB_OUTPUT_OPTIONS = SSFCRESOP

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

IF SY-SUBRC = 0.

FL_OPEN = 'X'.

  • Only first time it opens dialog

  • CLEAR E_SSFCOMPOP-DIALOG.

  • SSFCTRLOP-NO_DIALOG = ' '.

ELSE.

  • Get print parameter choosen in the first print and

  • transfer them for next call of fm SSF_OPEN

MOVE-CORRESPONDING SSFCRESOP TO E_SSFCOMPOP.

ENDIF.

ENDIF.

  • Block open and close of smartform in FM

SSFCTRLOP-NO_OPEN = 'X'.

SSFCTRLOP-NO_CLOSE = 'X'.

AT NEW Zsortgroup.

IF NOT T_CUSTOMER[] IS INITIAL.

&&&&&& here the records of a particular sort group are stored in the 'T_customer[]' after this it gets into the Function FM_NAME, it does not execute any of the parameters of the FM and jumps to REfresh T_customer

why is it happenning that way??? and why is it not printing any statements

  • now call the generated function module

CALL FUNCTION FM_NAME

EXPORTING

  • archive_index =

  • archive_parameters =

control_parameters = SSFCTRLOP

  • mail_appl_obj =

  • mail_recipient =

  • mail_sender =

output_options = E_SSFCOMPOP

  • user_settings = 'X'

ZTOTAL = ZTOTALAMOUNT

ZSCAN_CODE = SCAN_NUMBER

  • zpartner = bpartner

Z_BDATE = E_DATE

ZADNUMBER = ADNUMBER

ZADNUMBER1 = ZZADNUMBER

ZAGENCYNUMBER = AGENCYNUMBER

Z_PAYMENT_TERMS = V_PAYMENT_TERMS

ZZADNAME = ADNAME1

ZADNAME = ADNAME

ZAGENCYNAME = AGENCYNAME

ZPHONE = BPHONE

ZCREDITGROUP = ZCREDITTEXT

Z_BPERIOD = MONTHN

ZTOTALCREDITS = ZAPPLIEDCREDITS1

ZTOTALBALANCE = ZCURRENTTOTAL

ZZEXTZIP = ZZEXTENSIONZIP

  • bookings = bookings

  • importing document_output_info =

  • job_output_info =

  • job_output_options =

TABLES

STRIBUNECUSTOMER = CUSTOMER

ACCOUNTDATA = T_CUSTOMER

ZCDATAR = ZCDATA

ZAGING = AGINGDATAITAB

ZADDRESS = I_ADDRESS_NUMBER

EXCEPTIONS FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

REFRESH T_CUSTOMER.

ENDIF.

ENDAT.

INSERT FINAL_ACCITAB INTO TABLE T_CUSTOMER.

ENDLOOP.

CALL FUNCTION 'SSF_CLOSE'.

How can i take it from here??

Thanks in advance.

Vinu

0 Kudos
61

Try this:

DATA:SSFCTRLOP TYPE SSFCTRLOP,

SSFCTRLOP_OPEN TYPE SSFCTRLOP,

SSFCRESOP TYPE SSFCRESOP,

E_SSFCOMPOP TYPE SSFCOMPOP,

SORT LIKE FINAL_ACCITAB-ZSORTGROUP,

FL_OPEN,

T_CUSTOMER LIKE STANDARD TABLE OF FINAL_ACCITAB.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

FORMNAME = P_FORM

IMPORTING

FM_NAME = FM_NAME

EXCEPTIONS

NO_FORM = 1

NO_FUNCTION_MODULE = 2

OTHERS = 3.

LOOP AT FINAL_ACCITAB.

IF FINAL_ACCITAB-ZSORTGROUP <> SORT.

SORT = FINAL_ACCITAB-ZSORTGROUP.

IF NOT E_SSFCOMPOP IS INITIAL.

  • After first time dialog doesn't open

SSFCTRLOP_OPEN-NO_DIALOG = 'X'.

ENDIF.

IF FL_OPEN = 'X'.

CALL FUNCTION 'SSF_CLOSE'.

ENDIF.

CALL FUNCTION 'SSF_OPEN'

EXPORTING

USER_SETTINGS = SPACE

OUTPUT_OPTIONS = E_SSFCOMPOP

CONTROL_PARAMETERS = SSFCTRLOP_OPEN

IMPORTING

JOB_OUTPUT_OPTIONS = SSFCRESOP

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

IF SY-SUBRC = 0.

FL_OPEN = 'X'.

  • Get print parameter choosen in the first print and

  • transfer them for next call of fm SSF_OPEN

MOVE-CORRESPONDING SSFCRESOP TO E_SSFCOMPOP.'.

ENDIF.

ENDIF.

  • Block open and close of smartform in FM

SSFCTRLOP-NO_OPEN = 'X'.

SSFCTRLOP-NO_CLOSE = 'X'.

  • AT NEW ZSORTGROUP.

  • I don't know how you have called the field with customer number, but you make a print

  • foR every customer

AT NEW CUSTOMER_NUMBER.

IF NOT T_CUSTOMER[] IS INITIAL.

  • now call the generated function module

CALL FUNCTION FM_NAME

EXPORTING

CONTROL_PARAMETERS = SSFCTRLOP

ZTOTAL = ZTOTALAMOUNT

ZSCAN_CODE = SCAN_NUMBER

Z_BDATE = E_DATE

ZADNUMBER = ADNUMBER

ZADNUMBER1 = ZZADNUMBER

ZAGENCYNUMBER = AGENCYNUMBER

Z_PAYMENT_TERMS = V_PAYMENT_TERMS

ZZADNAME = ADNAME1

ZADNAME = ADNAME

ZAGENCYNAME = AGENCYNAME

ZPHONE = BPHONE

ZCREDITGROUP = ZCREDITTEXT

Z_BPERIOD = MONTHN

ZTOTALCREDITS = ZAPPLIEDCREDITS1

ZTOTALBALANCE = ZCURRENTTOTAL

ZZEXTZIP = ZZEXTENSIONZIP

TABLES

STRIBUNECUSTOMER = CUSTOMER

ACCOUNTDATA = T_CUSTOMER

ZCDATAR = ZCDATA

ZAGING = AGINGDATAITAB

ZADDRESS = I_ADDRESS_NUMBER

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

  • After printing data, clear them.

REFRESH T_CUSTOMER.

CLEAR: ZTOTALAMOUNT, .......

ENDIF.

ENDAT.

INSERT FINAL_ACCITAB INTO TABLE T_CUSTOMER.

  • Remember: when you execute a print, you are printin the data of previous customer,

  • so here save his parameters:

ZTOTALAMOUNT = ....

SCAN_NUMBER = ....

E_DATE = .....

.............

ENDLOOP.

  • Remeber: the data of last customer can't print into loop, so call smartform out of it:

IF FL_OPEN = 'X'.

CALL FUNCTION FM_NAME

EXPORTING

CONTROL_PARAMETERS = SSFCTRLOP

CALL FUNCTION 'SSF_CLOSE'.

ENDIF.

Max

0 Kudos
61

hi Max,

The major stumbling block is coming here... I found out an runtime error

AT NEW Zadvertiser ( I AM SORRY ABOUT THAT .. ZADVERTISER IS A FIELD IN 'FINAL_ACCITAB').

IF NOT T_CUSTOMER[] IS INITIAL.

the records of a particular ADVERTISER/CUSTOMER are stored in the 'T_customer[]'

once all the records of a customer arer stored,

it gets into the Function FM_NAME, it does not execute any of the parameters of the FM and jumps to REfresh T_customer

Because it is telling me that an interface parameter is not defined and missing in the FM module.

The weird thing is I have not touched that part and yesterday I was able to print some statements and I never came across an error like this and now it is throwing the runtime error

I checked it and I have declared that parameter in the smartform and in the print program.

I am having no clue why this error is coming up? Does it have to do with any code change that I did today?

Thanks

Vinu

0 Kudos
61

Hi Vinu

Which is the parameter missing?

Check your code and parameters of smartform, if there is an error, it have to be there.

Max

0 Kudos
61

Hi

You can try to do this:

- go to smartform transaction, put your smartform name in the input field and push the icon 'TEST':

you'll be in function builder and be able to see the name of FM of smartform. COPY the name of FM.

- go to your program and replave the name of FM instead of variable FM_NAME

- go to 'Extended Sintax Check' (Program->Check->Extended prgram check) and run it;

now you can see if you call FM of smartform well.

Max

0 Kudos
61

the parameter 'zadname' is missing and zadname is declared in the smartform and the reason why I think it is behaving so wierd is theinterface parameters have been derieved after a series of queries and some calculations being done and the results have been stored in a variable that are passed on to the smartform,

right now they contain the values of the last customer record ( i mentioned you and you gave the peice of code for that)

but these parameter values have been derived using queries and for example to get the scancode has a spearate code that has a loop running for 43 times. for each customer, where do you think I fit them into this piece of code.

should I inlcude them within the

loop at final_accitab .. ... end loop.

Can you just helpme out here?

Thanks Vinu

0 Kudos
61

I don't understand your problem very well, but you should put them at the end of loop at final_accitab, where you save all parameters are moved to smartforms.

0 Kudos
61

let me explain :

for example to derive the value for parameter

Z_PAYMENT_TERMS = V_PAYMENT_TERMS

*----


*Payment terms

*----


types: begin of s_payment_terms,

zterm type knb1-zterm,

vtext type tvzbt-vtext,

end of s_payment_terms.

data: i_payment_terms type standard table of s_payment_terms

WITH HEADER LINE,

v_payment_terms type tvzbt-vtext.

select single * from tvzbt INNER JOIN knb1 ON tvzbtzterm = knb1zterm

into corresponding fields of i_payment_terms

where knb1~kunnr = zzbusinesspartner.

v_payment_terms = i_payment_terms-vtext.

My question is if I declare it within the loop then this piece of code will be processed every time including for each record of the customer

like that I have separate piece of code for ZSCAN, ZADNAME, ZAGENCYNAME.. does it not create aperformance issue and take along time to execute.

What I thought is there a way when the T_customer[] gets updated with records for a customer then we can go ahead and perform this piece of code so that this entire peice of code is executed only once for each csutomer instead of executing the code every time...

Hope you got it...

Thanks

Santhosh

0 Kudos
61

Ok! I've understand your problem.

Depend on which data you should get out.

I think you shoul do these queries before calling the fm of smartform.

Infact you call the smartform for each customer, so you can do these queries only one time.

In your example you should place the query before call FM of smartform:

AT NEW Zadvertiser

select single * from tvzbt INNER JOIN knb1 ON

tvzbtzterm = knb1zterm

into corresponding fields of i_payment_terms

where knb1~kunnr = zzbusinesspartner.

v_payment_terms = i_payment_terms-vtext.

CALL FM_NAME

ENDAT.

Max

Message was edited by: max bianchi

0 Kudos
61

Thanks a lot Max, it really helped i was able to find the problem with parameter missing.

Have two questions here

1) While looping and processing the code 'AT New advertiser' the record in the headerlne of the table is very weird like this .....

advertiser agency date amount

10000548 ***** *** ******

and I need the agency (which is zzbusinesspartner) to carry out the query and get the data to update the variables in the form

How to solve this?

q2 while I loop through the final_accitab perform the queries for 'paymentterms ' , 'scan' it grabs the data for the next customer while the body is grabbing the data of the current customer

Can you help me here?

Thanks

Vinu

0 Kudos
61

1) The statament AT NEW <FIELD> runs when a value of a field at the right of <FIELD> is changed. All values of these fields are replace by '*'.

For example:

FIELD1 FIELD2 FIELD3 FIELD4 FIELD5

A B C D E

A B C D E

A C C D E

A C C D E

AT NEW FIELD3

It runs on first loop, becouse header line was initial and runs on 3rd row, becouse in the first and second rows the field1 and field2 have the same values A B.

It's as if the systems saw a string created concatenating the values of all fields at the left of FIELD3, so it says:

- First loop: string = FIELD1 + FIELD2 + FIELD3 = ABC

=> ABC <> initial => AT NEW runs

- Second loop: string = FIELD1 + FIELD2 + FIELD3 = ABC

- Third loop: string = FIELD1 + FIELD2 + FIELD3 = ACC

=> ACC <> ABC => AT NEW runs

.....

When it is in AT NEW/ENDAT the header line is

- First loop: ABC**

- Third loop: ACC**

So you should save the values of fields at the right of <FIELD> in a workarea before going into AT NEW/ENDAT:

MOVE ITAB TO WA.

AT NEW...

  • Here don't read ITAB but WA

ENDAT.

2) You can use event AT END OF <FIELD> instead of AT NEW, it runs when the last value is changed.

For example:

- First loop: string = FIELD1 + FIELD2 + FIELD3 = ABC

- Second loop: string = FIELD1 + FIELD2 + FIELD3 = ABC

AT END OF FIELD3 runs

- Third loop: string = FIELD1 + FIELD2 + FIELD3 = ACC

.....

So, when you are in the event AT END, the data of customer,that are in header line of table, are data you have to print.

If you this event you should update your code as:

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

FORMNAME = P_FORM

IMPORTING

FM_NAME = FM_NAME

EXCEPTIONS

NO_FORM = 1

NO_FUNCTION_MODULE = 2

OTHERS = 3.

LOOP AT FINAL_ACCITAB.

IF FINAL_ACCITAB-ZSORTGROUP <> SORT.

SORT = FINAL_ACCITAB-ZSORTGROUP.

IF NOT E_SSFCOMPOP IS INITIAL.

  • After first time dialog doesn't open

SSFCTRLOP_OPEN-NO_DIALOG = 'X'.

ENDIF.

IF FL_OPEN = 'X'.

CALL FUNCTION 'SSF_CLOSE'.

ENDIF.

CALL FUNCTION 'SSF_OPEN'

EXPORTING

USER_SETTINGS = SPACE

OUTPUT_OPTIONS = E_SSFCOMPOP

CONTROL_PARAMETERS = SSFCTRLOP_OPEN

IMPORTING

JOB_OUTPUT_OPTIONS = SSFCRESOP

EXCEPTIONS

.........................

  • Block open and close of smartform in FM

SSFCTRLOP-NO_OPEN = 'X'.

SSFCTRLOP-NO_CLOSE = 'X'.

  • Now you can place here the piece of code where you load

  • the parameters you move to smartforms.

INSERT FINAL_ACCITAB INTO TABLE T_CUSTOMER.

  • Remember: when you execute a print, you are printin the data of previous customer,

  • so here save his parameters:

ZTOTALAMOUNT = ....

SCAN_NUMBER = ....

E_DATE = .....

.............

AT END advertiser.

CALL FUNCTION FM_NAME

..............

  • After printing data, clear them.

REFRESH T_CUSTOMER.

CLEAR: ZTOTALAMOUNT, .......

ENDAT.

ENDLOOP.

It doesn't need to write the code to print last customer, now you can print all into LOOP/ENDLOOP

Max

Message was edited by: max bianchi

Message was edited by: max bianchi

0 Kudos
61

hi Max,

Here is my latest code...

DATA:SSFCTRLOP TYPE SSFCTRLOP,

SSFCTRLOP_OPEN TYPE SSFCTRLOP,

SSFCRESOP TYPE SSFCRESOP,

E_SSFCOMPOP TYPE SSFCOMPOP,

SORT LIKE FINAL_ACCITAB-ZSORTGROUP,

FL_OPEN,

T_CUSTOMER LIKE STANDARD TABLE OF FINAL_ACCITAB.

call function 'SSF_FUNCTION_MODULE_NAME'

exporting formname = p_form

  • variant = ' '

  • direct_call = ' '

importing fm_name = fm_name

exceptions no_form = 1

no_function_module = 2

others = 3.

LOOP AT FINAL_ACCITAB.

IF FINAL_ACCITAB-ZSORTGROUP <> SORT.

SORT = FINAL_ACCITAB-ZSORTGROUP.

IF NOT E_SSFCOMPOP IS INITIAL.

  • After first time dialog doesn't open

SSFCTRLOP_OPEN-NO_DIALOG = 'X'.

ENDIF.

IF FL_OPEN = 'X'.

CALL FUNCTION 'SSF_CLOSE'.

ENDIF.

CALL FUNCTION 'SSF_OPEN'

EXPORTING

USER_SETTINGS = SPACE

OUTPUT_OPTIONS = E_SSFCOMPOP

CONTROL_PARAMETERS = SSFCTRLOP_OPEN

IMPORTING

JOB_OUTPUT_OPTIONS = SSFCRESOP

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

IF SY-SUBRC = 0.

FL_OPEN = 'X'.

  • Get print parameter choosen in the first print and

  • transfer them for next call of fm SSF_OPEN

MOVE-CORRESPONDING SSFCRESOP TO E_SSFCOMPOP.

ENDIF.

ENDIF.

  • Block open and close of smartform in FM

SSFCTRLOP-NO_OPEN = 'X'.

SSFCTRLOP-NO_CLOSE = 'X'.

if zzadvertiser ne final_accitab-zadvertiser and zzadvertiser ne ' '. (instead of AT NEW zadvertiser)

      • aging

.

.

.

ZCURRENT = agingdataitab1-RAST1.

ZOVER30 = agingdataitab1-RAST2.

ZOVER60 = agingdataitab1-RAST3.

ZOVER90 = agingdataitab1-RAST4.

ZTOTALAMOUNT = ZCURRENT + ZOVER30 + ZOVER60 + ZOVER90 +

zappliedcredits1.

    • payment terms

.

.

.

    • address , adname, adnumber

.

.

.

    • scan number

.

.

.

IF NOT T_CUSTOMER[] IS INITIAL.

  • now call the generated function module

CALL FUNCTION '/1BCDWB/SF00000013'

EXPORTING

  • archive_index =

  • archive_parameters =

control_parameters = SSFCTRLOP

  • mail_appl_obj =

  • mail_recipient =

  • mail_sender =

  • output_options = E_SSFCOMPOP

  • user_settings = 'X'

ZTOTAL = ZTOTALAMOUNT

ZSCAN_CODE = SCAN_NUMBER

  • zpartner = bpartner

Z_BDATE = E_DATE

ZADNUMBER = ADNUMBER

ZADNUMBER1 = ZZADNUMBER

ZAGENCYNUMBER = AGENCYNUMBER

Z_PAYMENT_TERMS = V_PAYMENT_TERMS

ZADNAME = ADNAME

ZZADNAME = ADNAME1

ZAGENCYNAME = AGENCYNAME

ZPHONE = BPHONE

ZCREDITGROUP = ZCREDITTEXT

Z_BPERIOD = MONTHN

ZTOTALCREDITS = ZAPPLIEDCREDITS1

ZTOTALBALANCE = ZCURRENTTOTAL1

ZZEXTZIP = ZZEXTENSIONZIP

TABLES

STRIBUNECUSTOMER = CUSTOMER

ACCOUNTDATA = T_CUSTOMER

ZCDATAR = ZCDATA

ZAGING = AGINGDATAITAB1

ZADDRESS = I_ADDRESS_NUMBER

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

REFRESH T_CUSTOMER.

ENDIF.

  • ENDAT.

zzadvertiser = final_accitab-zadvertiser.

zzbusinesspartner = final_accitab-zagency.

refresh T_CUSTOMER.

endif.

INSERT FINAL_ACCITAB INTO TABLE T_CUSTOMER.

  • append final_accitab.

zzadvertiser = final_accitab-zadvertiser.

zzbusinesspartner = final_accitab-zagency.

ENDLOOP.

For the last customer.....

How to get the data for payment terms, adnumber, adname, for the last customer while using

the below..

IF FL_OPEN = 'X'.

CALL FUNCTION FM_NAME

EXPORTING

CONTROL_PARAMETERS = SSFCTRLOP

ZTOTAL = ZTOTALAMOUNT

ZSCAN_CODE = SCAN_NUMBER

Z_BDATE = E_DATE

ZADNUMBER = ADNUMBER

ZADNUMBER1 = ZZADNUMBER

ZAGENCYNUMBER = AGENCYNUMBER

Z_PAYMENT_TERMS = V_PAYMENT_TERMS

ZADNAME = ADNAME

ZZADNAME = ADNAME1

ZAGENCYNAME = AGENCYNAME

ZPHONE = BPHONE

ZCREDITGROUP = ZCREDITTEXT

Z_BPERIOD = MONTHN

ZTOTALCREDITS = ZAPPLIEDCREDITS1

ZTOTALBALANCE = ZCURRENTTOTAL

ZZEXTZIP = ZZEXTENSIONZIP

TABLES

STRIBUNECUSTOMER = CUSTOMER

ACCOUNTDATA = T_CUSTOMER

ZCDATAR = ZCDATA

ZAGING = AGINGDATAITAB1

ZADDRESS = I_ADDRESS_NUMBER

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

REFRESH T_CUSTOMER.

CALL FUNCTION 'SSF_CLOSE'.

ENDIF.

Question 2:

I have the data in 'final_accitab' as follows:

zadvertiser zagency ....................zsortgroup

100000065 100000065 1

100000065 100000065 1

.

.

100000070 100000070 1

100000071 100000071 2 and so on

I am able to pull in the relevant line items for each customer UNABLE TO GENERATE SEPARATE SPOOL REQUESTS BASED ON THE SORT GROUP

I AM GETTING A SINGLE SPOOL REQUEST CONTAIN STATEMENTS FOR VARIOUS SORT TYPES hOW TO CHANGE THAT?

IW OUDL REALLY APPRECIATE IF YOU COULD TAKE ALOOK INTO MY CODE AND HELP ME OUT HERE..

THANKS IN ADVANCE

VINU

0 Kudos
61

Also, max

Also, In the spool request, I am not getting to print the statements (100000065) for the first customer and it is printing the statement for (100000070), even if I am able to generate all the statements in a single spool request that is fine too.

I need your help in this urgent!!!

Thanks

Vinu

0 Kudos
61

I'm working for you....

0 Kudos
61

Thank you so much, for helping me out here. I really appreciate it.

Vinu

0 Kudos
61

Hi Vinu

I run this code and it works fine:

DATA: BEGIN OF FINAL_ACCITAB OCCURS 10,

ZADVERTISER TYPE KUNNR,

ZAGENCY TYPE KUNNR,

ZSORTGROUP(1) TYPE N,

END OF FINAL_ACCITAB.

DATA: SSFCTRLOP TYPE SSFCTRLOP,

SSFCTRLOP_OPEN TYPE SSFCTRLOP,

SSFCRESOP TYPE SSFCRESOP,

E_SSFCOMPOP TYPE SSFCOMPOP,

SORT LIKE FINAL_ACCITAB-ZSORTGROUP,

ZZADVERTISER LIKE FINAL_ACCITAB-ZADVERTISER,

ZZBUSINESSPARTNER LIKE FINAL_ACCITAB-ZAGENCY,

FL_OPEN,

T_CUSTOMER LIKE STANDARD TABLE OF FINAL_ACCITAB WITH HEADER LINE,

FL_CUSTOMER_PRINT.

DATA FM_NAME TYPE RS38L_FNAM.

FINAL_ACCITAB-ZADVERTISER = '100000065'.

FINAL_ACCITAB-ZAGENCY = '100000065'.

FINAL_ACCITAB-ZSORTGROUP = '1'.

APPEND FINAL_ACCITAB.

FINAL_ACCITAB-ZADVERTISER = '100000065'.

FINAL_ACCITAB-ZAGENCY = '100000065'.

FINAL_ACCITAB-ZSORTGROUP = '1'.

APPEND FINAL_ACCITAB.

FINAL_ACCITAB-ZADVERTISER = '100000065'.

FINAL_ACCITAB-ZAGENCY = '100000065'.

FINAL_ACCITAB-ZSORTGROUP = '1'.

APPEND FINAL_ACCITAB.

FINAL_ACCITAB-ZADVERTISER = '100000066'.

FINAL_ACCITAB-ZAGENCY = '100000066'.

FINAL_ACCITAB-ZSORTGROUP = '1'.

APPEND FINAL_ACCITAB.

FINAL_ACCITAB-ZADVERTISER = '100000066'.

FINAL_ACCITAB-ZAGENCY = '100000066'.

FINAL_ACCITAB-ZSORTGROUP = '1'.

APPEND FINAL_ACCITAB.

FINAL_ACCITAB-ZADVERTISER = '100000067'.

FINAL_ACCITAB-ZAGENCY = '100000067'.

FINAL_ACCITAB-ZSORTGROUP = '1'.

APPEND FINAL_ACCITAB.

FINAL_ACCITAB-ZADVERTISER = '100000068'.

FINAL_ACCITAB-ZAGENCY = '100000068'.

FINAL_ACCITAB-ZSORTGROUP = '2'.

APPEND FINAL_ACCITAB.

FINAL_ACCITAB-ZADVERTISER = '100000068'.

FINAL_ACCITAB-ZAGENCY = '100000068'.

FINAL_ACCITAB-ZSORTGROUP = '2'.

APPEND FINAL_ACCITAB.

FINAL_ACCITAB-ZADVERTISER = '100000069'.

FINAL_ACCITAB-ZAGENCY = '100000069'.

FINAL_ACCITAB-ZSORTGROUP = '2'.

APPEND FINAL_ACCITAB.

FINAL_ACCITAB-ZADVERTISER = '100000070'.

FINAL_ACCITAB-ZAGENCY = '100000070'.

FINAL_ACCITAB-ZSORTGROUP = '2'.

APPEND FINAL_ACCITAB.

FINAL_ACCITAB-ZADVERTISER = '100000070'.

FINAL_ACCITAB-ZAGENCY = '100000070'.

FINAL_ACCITAB-ZSORTGROUP = '2'.

APPEND FINAL_ACCITAB.

FINAL_ACCITAB-ZADVERTISER = '100000071'.

FINAL_ACCITAB-ZAGENCY = '100000071'.

FINAL_ACCITAB-ZSORTGROUP = '3'.

APPEND FINAL_ACCITAB.

FINAL_ACCITAB-ZADVERTISER = '100000072'.

FINAL_ACCITAB-ZAGENCY = '100000072'.

FINAL_ACCITAB-ZSORTGROUP = '3'.

APPEND FINAL_ACCITAB.

FINAL_ACCITAB-ZADVERTISER = '100000073'.

FINAL_ACCITAB-ZAGENCY = '100000073'.

FINAL_ACCITAB-ZSORTGROUP = '4'.

APPEND FINAL_ACCITAB.

SORT FINAL_ACCITAB BY ZSORTGROUP ZADVERTISER ZAGENCY.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

FORMNAME = 'ZSF_TEST'

IMPORTING

FM_NAME = FM_NAME

EXCEPTIONS

NO_FORM = 1

NO_FUNCTION_MODULE = 2

OTHERS = 3.

LOOP AT FINAL_ACCITAB.

IF FINAL_ACCITAB-ZSORTGROUP <> SORT.

PERFORM CALL_SMARTFORM.

SORT = FINAL_ACCITAB-ZSORTGROUP.

IF NOT E_SSFCOMPOP IS INITIAL.

  • After first time dialog doesn't open

SSFCTRLOP_OPEN-NO_DIALOG = 'X'.

ENDIF.

IF FL_OPEN = 'X'.

CALL FUNCTION 'SSF_CLOSE'.

ENDIF.

CALL FUNCTION 'SSF_OPEN'

EXPORTING

USER_SETTINGS = SPACE

OUTPUT_OPTIONS = E_SSFCOMPOP

CONTROL_PARAMETERS = SSFCTRLOP_OPEN

IMPORTING

JOB_OUTPUT_OPTIONS = SSFCRESOP

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

IF SY-SUBRC = 0.

FL_OPEN = 'X'.

MOVE-CORRESPONDING SSFCRESOP TO E_SSFCOMPOP.

ENDIF.

ENDIF.

  • Block open and close of smartform in FM

SSFCTRLOP-NO_OPEN = 'X'.

SSFCTRLOP-NO_CLOSE = 'X'.

IF ZZADVERTISER NE FINAL_ACCITAB-ZADVERTISER AND ZZADVERTISER NE ' '.

PERFORM CALL_SMARTFORM.

ENDIF.

INSERT FINAL_ACCITAB INTO TABLE T_CUSTOMER.

  • append final_accitab.

ZZADVERTISER = FINAL_ACCITAB-ZADVERTISER.

ZZBUSINESSPARTNER = FINAL_ACCITAB-ZAGENCY.

ENDLOOP.

PERFORM CALL_SMARTFORM.

IF FL_OPEN = 'X'.

CALL FUNCTION 'SSF_CLOSE'.

ENDIF.

&----


*& Form CALL_SMARTFORM

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM CALL_SMARTFORM .

IF NOT T_CUSTOMER[] IS INITIAL.

READ TABLE T_CUSTOMER INDEX 1.

  • now call the generated function module

CALL FUNCTION FM_NAME

EXPORTING

CONTROL_PARAMETERS = SSFCTRLOP

KUNNR = T_CUSTOMER-ZADVERTISER

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

REFRESH T_CUSTOMER.

ENDIF.

ENDFORM. " CALL_SMARTFORM

2) Get data of last customer at the of loop.

When dialog is open, CHOOSE OPTION TO CREATE A NEW SPOOL

Max

Message was edited by: max bianchi

Message was edited by: max bianchi

0 Kudos
61

Thanks Max, I was able to get the spool request running, the code really helped and I really appreciate for taking your time off helping me here.

I shall award full points to you.

Have anice weekend.

Vinu

0 Kudos
61

hi Max,

Read table customerperiod with key kunnr = final_accitab-zadvertiser.

    • zzadvertiser = final_accitab-zadvertiser.

icode2 = customerperiod-xausz.

if icode2 = '9'.

exit.

endif.

  • ZZADVERTISER = final_accitab-zadvertiser.

  • ZZBUSINESSPARTNER = final_accitab-zagency.

IF FINAL_ACCITAB-ZSORTGROUP <> SORT.

SSFCTRLOP_OPEN-NO_DIALOG = 'X'.

PERFORM CALL_SMARTFORM.

SORT = FINAL_ACCITAB-ZSORTGROUP.

IF NOT E_SSFCOMPOP IS INITIAL.

ENDIF.

IF FL_OPEN = 'X'.

CALL FUNCTION 'SSF_CLOSE'.

  • MJC20050910 begin

perform write_log.

  • MJC20050910 end

ENDIF.

E_SSFCOMPOP-TDDEST = 'Xerox1'.

  • Having an issue here, When I give the printer name as 'Default' it is generating spool requests while If I change the printer name as 'Xerox1' it is not generating any spool requests

  • E_SSFCOMPOP-TDNEWID = 'X'.

rest looks the same....

CALL FUNCTION 'SSF_OPEN'

EXPORTING

USER_SETTINGS = SPACE

OUTPUT_OPTIONS = E_SSFCOMPOP

CONTROL_PARAMETERS = SSFCTRLOP_OPEN

IMPORTING

JOB_OUTPUT_OPTIONS = SSFCRESOP

EXCEPTIONS

FORMATTING_ERROR = 1

INTERNAL_ERROR = 2

SEND_ERROR = 3

USER_CANCELED = 4

OTHERS = 5.

IF SY-SUBRC = 0.

FL_OPEN = 'X'.

  • Get print parameter choosen in the first print and

  • transfer them for next call of fm SSF_OPEN

MOVE-CORRESPONDING SSFCRESOP TO E_SSFCOMPOP.

ENDIF.

ENDIF.

  • Block open and close of smartform in FM

SSFCTRLOP-NO_OPEN = 'X'.

SSFCTRLOP-NO_CLOSE = 'X'.

*AT NEW Zadvertiser.

  • zzadvertiser = final_accitab-zadvertiser.

if zzadvertiser ne final_accitab-zadvertiser and zzadvertiser ne ' '.

PERFORM CALL_SMARTFORM.

ENDIF.

Can you tell me what's the problem is?

Thanks

Vinu