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

Multiple cheque print issue in Smartforms

0 Likes
611

Hi,

I am trying to print multiple cheque with the help of Z-Program but its overlaps in first page.

Below is my code.

If anyone knows the solution please reply soon.

*&---------------------------------------------------------------------*

*& Report  ZDRIVER_CHEQUE_PRINT

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

REPORT zfi_cheque_print.

TABLES payr.

PARAMETERS: p_bukrs TYPE bsak-bukrs OBLIGATORY,

             p_gjahr TYPE bsak-gjahr OBLIGATORY,

             p_hbkid TYPE payr-hbkid OBLIGATORY,

             p_hktid TYPE payr-hktid OBLIGATORY.

SELECT-OPTIONS:s_checf FOR payr-checf OBLIGATORY.

DATA: fm_name TYPE rs38l_fnam,

       sfname TYPE tdsfname.

DATA: amount TYPE pc207-betrg,

       amt_in_words(100).

DATA  lt_ssfcompop TYPE ssfcompop.

DATA  lw_ctrl TYPE ssfctrlop. "ssfcompop. "ctrl.

DATA  lw_ssfcrescl TYPE ssfcrescl.

DATA: BEGIN OF it_split OCCURS 0,

        ch(50),

       END OF it_split,

       wa_split LIKE LINE OF it_split.

DATA :amt_in_words1(100),

       amt_in_words2(100),

       text1(100) TYPE c ,

       text2(100) TYPE c .

TYPES: BEGIN OF ty_payr,

         lifnr TYPE lifnr,

         rwbtr TYPE rwbtr,

         zaldt TYPE payr-zaldt,

         znme1 TYPE payr-znme1,

         znme2 TYPE payr-znme2,

         znme3 TYPE payr-znme3,

         znme4 TYPE payr-znme4,

         checf TYPE payr-checf,

        END OF ty_payr.

TYPES: BEGIN OF ty_final,

         rwbtr TYPE rwbtr,

         name1(40) TYPE c,"lfa1-name1,

         amtinwords(100),

         amtinwords1(100),

         amtinwords2(100),

         name2(40) TYPE c,"lfa1-name2,

         name3(40) TYPE c,"lfa1-name3,

         name4(40) TYPE c,"lfa1-name4,

         bancd(8) TYPE c,"bancd,

         checf TYPE checf,

        END OF ty_final.

TYPES: BEGIN OF ty_lfa1,

        lifnr TYPE lfa1-lifnr,

        name1 TYPE  lfa1-name1,

        name2 TYPE  lfa1-name2,

        name3 TYPE  lfa1-name3,

        name4 TYPE  lfa1-name4,

       END OF ty_lfa1.

DATAit_payr TYPE TABLE OF ty_payr,

        wa_payr LIKE LINE OF it_payr,

        it_lfa1 TYPE TABLE OF ty_lfa1,

        wa_lfa1 LIKE LINE OF it_lfa1,

        it_final TYPE TABLE OF ty_final,

        wa_final TYPE ty_final,

        it_final2 TYPE TABLE OF ty_final,

        wa_final2 TYPE ty_final.

DATAcontrol_parameters  TYPE ssfctrlop,

        w_cnt TYPE i,

        w_cnt2 TYPE i.

DATA : wa_ssfcompop TYPE ssfcompop.

DATA : it_ssfcompop TYPE STANDARD TABLE OF ssfcompop.

DATA : rwbtr TYPE rwbtr,

        name1(40) TYPE c,"lfa1-name1,

        amtinwords(100),

        amtinwords1(100),

        amtinwords2(100),

        name2(40) TYPE c,"lfa1-name2,

        name3(40) TYPE c,"lfa1-name3,

        name4(40) TYPE c,"lfa1-name4,

        bancd     TYPE datum,"bancd,

        checf TYPE checf.

DATAcontrol TYPE ssfctrlop,

        errtab  TYPE tsferror.

START-OF-SELECTION.

break abapuser.

PERFORM refresh.

PERFORM get_data.

PERFORM call_sf.

PERFORM refresh.

*&---------------------------------------------------------------------*

*&      Form  REFRESH

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

FORM refresh .

CLEAR:fm_name,sfname,amount,amt_in_words,lt_ssfcompop,

       lw_ctrl,lw_ssfcrescl,wa_split,amt_in_words1,amt_in_words2,

       text1,text2,it_payr,wa_payr,it_lfa1,wa_lfa1,it_final,wa_final,

       it_final2,wa_final2,control_parameters,w_cnt,w_cnt2,wa_ssfcompop,

       it_ssfcompop,rwbtr,name1,amtinwords,amtinwords1,amtinwords2,

       name2,name3,name4,bancd,checf,control,errtab.

ENDFORM.

*&---------------------------------------------------------------------*

*&      Form  GET_DATA

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

FORM get_data .

   SELECT lifnr rwbtr zaldt znme1 znme2 znme3 znme4 checf

   FROM payr

    INTO TABLE it_payr

   WHERE zbukr = p_bukrs

   AND gjahr = p_gjahr

   AND hbkid = p_hbkid

   AND hktid = p_hktid

   AND checf IN s_checf.

   IF it_payr IS INITIAL.

     MESSAGE 'No data found' TYPE 'E'.

   ENDIF.

SELECT lifnr name1 name2 name3 name4

   FROM lfa1

   INTO CORRESPONDING FIELDS OF TABLE it_lfa1

   FOR ALL ENTRIES IN it_payr

   WHERE lifnr = it_payr-lifnr.

LOOP AT it_payr INTO wa_payr.

   IF wa_payr-rwbtr < 0.

     wa_final-rwbtr = wa_payr-rwbtr * -1.

   ELSE.

     wa_final-rwbtr = wa_payr-rwbtr.

   ENDIF.

   amount = wa_final-rwbtr.

   wa_final-bancd = wa_payr-zaldt.

   CONDENSE wa_final-bancd.

   READ TABLE it_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_payr-lifnr.

   IF sy-subrc = 0.

   wa_final-name1 = wa_lfa1-name1.

   wa_final-name2 = wa_lfa1-name2.

   wa_final-name3 = wa_lfa1-name3.

   wa_final-name4 = wa_lfa1-name4.

   ENDIF.

   CALL FUNCTION 'HR_IN_CHG_INR_WRDS'

     EXPORTING

       amt_in_num   = amount

     IMPORTING

       amt_in_words = amt_in_words.

   CONDENSE amt_in_words.

   CALL FUNCTION 'STRING_UPPER_LOWER_CASE'

     EXPORTING

       delimiter       = 'X'

       string1         = amt_in_words

    IMPORTING

      string          = amt_in_words

* EXCEPTIONS

*   NOT_VALID       = 1

*   TOO_LONG        = 2

*   TOO_SMALL       = 3

*   OTHERS          = 4

             .

   IF sy-subrc <> 0.

* Implement suitable error handling here

   ENDIF.

   CONDENSE amt_in_words.

   SPLIT amt_in_words AT space INTO TABLE it_split.

   CLEAR amt_in_words.

   LOOP AT it_split INTO wa_split.

     TRANSLATE wa_split-ch(1) TO UPPER CASE.

     CONCATENATE amt_in_words wa_split INTO amt_in_words

     SEPARATED BY space.

   ENDLOOP.

   SPLIT amt_in_words AT 'Rupees' INTO : text1 text2.

   IF text2 IS NOT INITIAL.

     CONCATENATE text1 'And' text2 INTO amt_in_words SEPARATED BY space.

   ENDIF.

   REPLACE 'Rupees' WITH '' INTO amt_in_words .

   CONCATENATE amt_in_words 'Only' INTO amt_in_words SEPARATED BY space.

   break abapuser.

   CONDENSE amt_in_words.

   CALL FUNCTION 'RKD_WORD_WRAP'

       EXPORTING

        textline                  = amt_in_words

        delimiter                 = ' '

        outputlen                 = 60

      IMPORTING

        out_line1                 = amt_in_words1

        out_line2                 = amt_in_words2

*       OUT_LINE3                 =

*     TABLES

*       OUT_LINES                 =

*     EXCEPTIONS

*       OUTPUTLEN_TOO_LARGE       = 1

*       OTHERS                    = 2

               .

     IF sy-subrc <> 0.

* Implement suitable error handling here

     ENDIF.

     CONDENSE amt_in_words1.

     CONDENSE amt_in_words2.

     wa_final-checf = wa_payr-checf.

     wa_final-amtinwords1 = amt_in_words1.

     wa_final-amtinwords2 = amt_in_words2 .

   APPEND wa_final TO it_final.

ENDLOOP.

ENDFORM.

*&---------------------------------------------------------------------*

*&      Form  CALL_SF

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

FORM call_sf .

   sfname = 'ZFI_CHEQUE_PRINT_V1'(001).

   CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

     EXPORTING

       formname           = sfname

*     VARIANT            = ' '

*     DIRECT_CALL        = ' '

     IMPORTING

       fm_name            = fm_name

     EXCEPTIONS

       no_form            = 1

       no_function_module = 2

       OTHERS             = 3.

   IF sy-subrc <> 0.

     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

   ENDIF.

*  control-no_dialog = ' '.

*  control-preview   = ' '.

   control-no_open   = 'X'.

   control-no_close  = 'X'.

   CALL FUNCTION 'SSF_OPEN'

     EXPORTING

*     ARCHIVE_PARAMETERS       =

*     USER_SETTINGS            = 'X'

*     MAIL_SENDER              =

*     MAIL_RECIPIENT           =

*     MAIL_APPL_OBJ            =

*     OUTPUT_OPTIONS           =

       control_parameters       = control

*   IMPORTING

*     JOB_OUTPUT_OPTIONS       =

     EXCEPTIONS

       formatting_error         = 1

       internal_error           = 2

       send_error               = 3

       user_canceled            = 4

       OTHERS                   = 5.

   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.

LOOP AT it_final INTO wa_final.

   CLEAR:amtinwords2,amount,amtinwords1,bancd,name1,name2,name3,name4.

   IF wa_final-amtinwords2 IS NOT INITIAL.

     amtinwords2 = wa_final-amtinwords2.

   ELSE.

     amtinwords2 = ' '.

   ENDIF.

   amount = wa_final-rwbtr.

   amtinwords1 = wa_final-amtinwords1.

   name1 = wa_final-name1.

   name2 = wa_final-name2.

   name3 = wa_final-name3.

   name4 = wa_final-name4.

   TRANSLATE name1+0(1) TO UPPER CASE.

   bancd = wa_final-bancd.

       CALL FUNCTION fm_name"'/1BCDWB/SF00000061'

         EXPORTING

*         ARCHIVE_INDEX              =

*         ARCHIVE_INDEX_TAB          =

*         ARCHIVE_PARAMETERS         =

           control_parameters         = control

*         MAIL_APPL_OBJ              =

*         MAIL_RECIPIENT             =

*         MAIL_SENDER                =

*          OUTPUT_OPTIONS             = wa_ssfcompop

*         USER_SETTINGS              = 'X'

           amount                     = amount

           rwbtr                      = rwbtr

           name1                      = name1

           amtinwords                 = amtinwords

           amtinwords1                = amtinwords1

           amtinwords2                = amtinwords2

           name2                      = name2

           name3                      = name3

           name4                      = name4

           bancd                      = bancd

           checf                      = checf

*       IMPORTING

*         DOCUMENT_OUTPUT_INFO       =

*         JOB_OUTPUT_INFO            =

*         JOB_OUTPUT_OPTIONS         =

        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.

       ENDIF.

     break abapuser.

ENDLOOP.

CALL FUNCTION 'SSF_CLOSE'

*   IMPORTING

*     JOB_OUTPUT_INFO        =

     EXCEPTIONS

       formatting_error       = 1

       internal_error         = 2

       send_error             = 3

       OTHERS                 = 4.

   IF sy-subrc <> 0.

     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

   ENDIF.

ENDFORM.

3 REPLIES 3
Read only

Former Member
0 Likes
569

instead of calling the Smartform inside the loop ... call the smartforms and do the looping inside SF by passing the whole table inside SF using the exporting parameters.

Let me know if you need more help.

Hope this helps.

Read only

Former Member
0 Likes
569

Hi

provide output screen shot  for better solution.

regards,

Chandu

Read only

0 Likes
569

Thank you so much guys...

Issue has been resolved....