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: 

No. of Labels as Input in Smartform Label Printing

yarnagula_sudhir
Active Participant
0 Kudos

Hi Smartform Experts,

My requirement is to print Smartform Label Printing based on No. of Label numbers as Input.

Kindly find the below screen shots.

1. Input: Sales Order

2. ALV Grid Display, where you can find No. of Labels as Input again

3. After entering No. of Labels. Press SAVE to call Smartfrom.

4. Sending the Internal Table to the Smartfrom.

5. Now the Report Internal Table will be the Input for the Smartfrom at Form Interface -> Tables

6. As they are three line items, i'm getting three 3 labels on Smartfrom screen

Doubts:

1. What will be the LOGIC to print as below and where exactly should i write the Logic?

    Line Item 1 -> 3 Lables  -> 3 Times

    Line Item 2 -> 4 Labels -> 4 Times

    Line Item 3 -> 5 Labels -> 5 Times

Kindly let me know the solution.

With Regards,

Sudhir.

1 ACCEPTED SOLUTION

VenkatRamesh_V
Active Contributor
0 Kudos

Before passing to smartforms.

create a it_temp internal table.

loop at alv_itab into wa.

CHECk wa-lable IS NOT inital.

Do wa-lable times.

MOVE-Corresponding wa to wa_temp.

append wa_temp to it_temp.

Clear wa_temp.

END DO.

endloop.

pass the it_temp to smartforms.

Hope it helpful,

Regards,

Venkat.V

21 REPLIES 21

former_member202818
Active Contributor
0 Kudos

Hi Yarnagula,

In driver program.

"Get total times of smartform call

Loop lt_final into wa_final.

gv_tot_pages = gv_tot_pages + wa_final-no_of_labels.

endloop.

Loop lt_final into wa_final.

do wa_final-no_of_labels times.

gv_index = gv_index + 1.

perform set_control_para.

   call smarform by passing wa_final, control parameter( to create a single pool and avoid popup asking for each smartform call) and output options..

enddo.

endloop.

*******************

form set_control_para.

  gwa_control_parameters-no_dialog = abap_false.          "No Dailog Display

   gwa_control_parameters-preview = abap_true"Show Preview

   gwa_outoptions-tddest          = gcon_device. "LOCL' Device name

   gwa_outoptions-tdimmed         = abap_true" Print immediately

CASE gv_index.

     WHEN 1.

       gwa_control_parameters-no_open  = abap_false. " Open

       gwa_control_parameters-no_close = abap_true" No Close

     WHEN gv_tot_pages.

       gwa_control_parameters-no_open  = abap_true"No Open

       gwa_control_parameters-no_close = abap_false. "Close

     WHEN OTHERS.

       gwa_control_parameters-no_open  = abap_true"No Open

       gwa_control_parameters-no_close = abap_true"No Close

ENDCASE.

endfom.


Regards

Sreekanth

0 Kudos


Hi Sreekanth,

As of now output options/printer settings is not the problem.

Kindly let me know the logic of how to print smartfrom as below:

    Line Item 1 -> 3 Lables  -> 3 Times

    Line Item 2 -> 4 Labels -> 4 Times

    Line Item 3 -> 5 Labels -> 5 Times

With Regards,

Sudhir.

0 Kudos

Did u go through my logic? is that fit for u?

gwa_control_parameters TYPE ssfctrlop, "Form Control Parameters

gwa_outoptions       TYPE ssfcompop,           " Output Options

0 Kudos


Ya I've gone through your logic. But it didn't work out for my requirement.

Your Logic:

   DATA: gv_tot_pages TYPE numc3,
      gv_index TYPE I.

Loop at lt_final into ls_final.
  gv_tot_pages = gv_tot_pages + ls_final-no_of_labels.
endloop.

Loop at lt_final into ls_final.
  do ls_final-no_of_labels times.
    gv_index = gv_index + 1.
  enddo.
endloop.

1. My ALV Internal Table came to my Smartfrom

2. As my internal table contains Three (3) line items, in smartform i got Three (3) line items as Three (3) boxes.

3. According to my requirement,

    first box or first line item should comes 3 times as (No. of label = 3)

    second box or second line item should comes 4 times as (No. of label = 4)

    third box or third line item should comes 5 times as (No. of label = 5).

Now kindly let me know the exact logic and where exactly should i write it.

With Regards,

Sudhir.

  

0 Kudos

Ok, now i got the requirement.

This can be done using Table element in smartform.

Since each line has to display 2 boxes, design the line type with 2 boxes.

Declare an internal table(itab2) which can hold 2 boxes data in a line.

Process lt_final into itab2. So that as u mentioned itab2 will have 6 (3+4+5)/2) items.

Then pass itab2.

Regards

Sreekanth

former_member202818
Active Contributor
0 Kudos

Code to process itab1 to itab2.

delete table itab1 where no_of_labels = 0.

loop itab1 into wa1.

lv_tabix = sy-tabix.

do (wa-no_of_labels / 2) times.

    fill 2 boxes data in wa2 with wa1.

    append wa2 to itab2.

enddo.

if (wa-no_of_labels / 2) <> 0. "In case of odd numbers

   read table itab1 into wa1 index lv_tabix + 1.

    if sy-subrc <> 0.

      clear wa1.

    endif.

    fill 2nd box data into wa2 from wa1.

    append wa2 to itab2.

endif.

clear wa2.

endloop.

0 Kudos

Hi Srekanth,

Thank you for your reply.

Your assumption is wrong. Its not (Since each line has to display 2 boxes, design the line type with 2 boxes.).

1. Observe the Input in ALV Display. Observe No. of Labels field.

2. If First Line Item contains 10 as No.of Labels. Then first box or first line item should come 10 times.

   Similarly Second line items -> 20 -> 20 boxes

                 Third line items -> 30 -> 30 boxes.

As this is Label Printing, this is the requirement. Kindly let me know whether the requirement is clear or not. If not I will explain to you again.

With Regards,

Sudhir.

VenkatRamesh_V
Active Contributor
0 Kudos

Before passing to smartforms.

create a it_temp internal table.

loop at alv_itab into wa.

CHECk wa-lable IS NOT inital.

Do wa-lable times.

MOVE-Corresponding wa to wa_temp.

append wa_temp to it_temp.

Clear wa_temp.

END DO.

endloop.

pass the it_temp to smartforms.

Hope it helpful,

Regards,

Venkat.V

0 Kudos


Hi Venkat,

Thank you for your reply. Kindly let me know whether yor code applicable for the following requirement.

Requirement:

1. Observe the Input in ALV Display. Observe No. of Labels field.

2. If First Line Item contains 10 as No.of Labels. Then first box or first line item should come 10 times.

   Similarly Second line items -> 20 -> 20 boxes

                 Third line items -> 30 -> 30 boxes.

Will your code works similar. Kindly let me know.

With Regards,

Sudhir.

0 Kudos

Hi,

before passing the internal table to smartforms.

I am appending the records based on no of labels.

using DO END  statement.

Then passing internal table to smart forms.

Hope it helpful,

Regards,

Venkat.

0 Kudos

Thank you so much Venkat. You are Awesome.

My requirement is done. Thanks alot.

With Regards,

Sudhir.

0 Kudos


Hi Venkat,

Kindly find the below Picture. If any field value is empty or its quantity is '0', how to restrict in displaying those fields in smartform.

As the above fields are empty or zero, i dont want to display them in smartfrom. how to restrict them. KIndly let me know the solution.

With Regards,

Sudhir.

0 Kudos

Hi,

Check the link.

Hope it helpful,

Regards,

Venkat.

0 Kudos

Hi Venkat,

Thank you for your reply. The link was helpful but not enough.

Find the below Picture.

1. As Color is Empty, I dont want to print that line color in Smartform.

2. If im using '&WA1-KBETR(I)&' , then MRP which is '0.00' changed to empty fine, but

                                                       if MRP which is '300.00' getting space in front.

Note: We cannot use &WA1-KBETR(C)&' and &WA1-KBETR(I)&' two times for one field.

Kindly let me know the solution.

With Regards,

Sudhir.

0 Kudos

&WA1-KBETR(CIZ)&'

0 Kudos

Thanks sreekanth its working. Thanks alot.

With Regards,

Sudhir.

0 Kudos

Hi Sreekanth,

How to restrict EMPTY fields in Smartform. Find the below Picture.

As the Color and MRP field is Empty, I dont want to display those fields at smartform level.

Kindly let me know the solution.

With Regards,

Sudhir.

0 Kudos

Give condition for text element, that is the variable value is not initial.

0 Kudos

Of course i've given at condition tab as "WA1-ZZCOLOR1  # INITIAL".

But its restricting the entire Line item or entire Box. Means, if color is initial, entire line item box is not displaying.

Kindly let me know the solution.

With Regards,

Sudhir.

0 Kudos

Keep each text(eg:color) in each text element