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: 

Smartform dynamic

Former Member
0 Kudos
Good morning experts , I have a report that calls a SmartForm , income production date ( 12/12/13 ) and orders ( 000111-000113 ) , and the SmartForm each order is placed on a page, but the detail appears in duplicate , I mean:

000111 The order should only display its details , however it shows detail of 000112 and 000113 orders .

This I have done in the SmartForm :
interface
t_head like structure
t_det like structure

Global definitions
st_head type structure
st_det type structure ( detail)
g_tab type sy- Tabix
g_count type sy- Tabix
g_lines type num
g_tab1 type sy- Tabix
it_det type structure ( detail)

I declare in the loop so to bring detail T_DET INTO ST_DET .

And in the line of the program i use this:
Input Parameters : it_det , g_tab , g_tab1 , g_lines , st_det
Output Parameters : g_Tab , g_tab1 , g_count

add 1 to g_tab .

REFRESH : it_det .

it_det [ ] = t_det [ ] .
DELETE WHERE it_det budat st_det - budat NE .

DESCRIBE TABLE it_det [ ] LINES g_lines .

I created the command and in the condition I put the following:
g_tab = g_lines
g_count < g_tab1


Please can you help me just to show details as corresponding to each order.

I welcome your comments .

Thanks for your valuable time.

1 ACCEPTED SOLUTION

nishantbansal91
Active Contributor
0 Kudos

HI Brujo,

As am i understood from your question is that you want to print the one order in one page.

So when you have the internal table in all the Orders instead of making it more complex.


Do simple thing Inside your program line define one variable.

data flag type Char.

data gl_idx type sy-tabix,

Loop at it_itab into wa_itab. " Example loop in the main window.

  gl_idx = sy-tabix + 1.                    " Increase the index of the loop.

 

read table it_itab into ls_itab index gl_idx " Read the next index. " Code inside your program line.

 

if wa_itab-aufnr  = ls_itab-aufnr. " if the next order is same of the current order number.

Set

flag = 'X'.

else.

flag = ' '.

endif.

At last of the Main area use the command if the flag value is space.

endloop.

Let me know if you have other issue.

Regards.

Nishant Bansal.

6 REPLIES 6

nishantbansal91
Active Contributor
0 Kudos

HI Brujo,

As am i understood from your question is that you want to print the one order in one page.

So when you have the internal table in all the Orders instead of making it more complex.


Do simple thing Inside your program line define one variable.

data flag type Char.

data gl_idx type sy-tabix,

Loop at it_itab into wa_itab. " Example loop in the main window.

  gl_idx = sy-tabix + 1.                    " Increase the index of the loop.

 

read table it_itab into ls_itab index gl_idx " Read the next index. " Code inside your program line.

 

if wa_itab-aufnr  = ls_itab-aufnr. " if the next order is same of the current order number.

Set

flag = 'X'.

else.

flag = ' '.

endif.

At last of the Main area use the command if the flag value is space.

endloop.

Let me know if you have other issue.

Regards.

Nishant Bansal.

0 Kudos

Thank you for responding, if I need to display a page in order SmartForm, the code that describes where you write, in the report that calls the SmartForm?, and the command where I declare the variable flag, i send you the code I'm using in the report:


DATA: gt_result TYPE STANDARD TABLE OF gty_result, "gty_result = internal table
      gs_result LIKE LINE OF gt_result.


DATA: st_head     TYPE ypp_ordenaufm_head,"HEAD STRUCTURE
      it_head     TYPE STANDARD TABLE OF ypp_ordenaufm_head,
      st_det      TYPE ypp_ordenaufm_det,"MAIN STRUCTURE
      it_det      TYPE STANDARD TABLE OF ypp_ordenaufm_det


LOOP AT gt_result ASSIGNING <fs_datos>.
     CLEAR: st_head, st_det.
     st_head-budat = <fs_datos>-budat.
     st_head-maktx = <fs_datos>-maktx.
     st_head-matnr = <fs_datos>-matnr.
     st_head-aufnr = <fs_datos>-aufnr.
     APPEND st_head TO it_head.

     st_det-budat = <fs_datos>-budat.
     st_det-turno = <fs_datos>-turno.
     st_det-charg = <fs_datos>-charg.
     g_total = <fs_datos>-erfmg + g_total.
     APPEND st_det TO it_det.

ENDLOOP.


FORM print_smartform .

   IF cf_retcode = 0.
     CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
       EXPORTING
         formname           = 'Y_PP_DYNAMIC' "SMARTFORM
       IMPORTING
         fm_name            = lf_fm_name
       EXCEPTIONS
         no_form            = 1
         no_function_module = 2
         OTHERS             = 3.
     IF sy-subrc <> 0.
       cf_retcode = sy-subrc.
       MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
       WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
     ENDIF.
   ENDIF.

*  BREAK-POINT.
   IF cf_retcode = 0.
     t_ssfcompop-tdpageslct = space.
     t_ssfcompop-tdnewid    = 'X'.
     t_ssfcompop-tddelete   = 'X'.
     t_ssfcompop-tdnoprint  = ' '.
     t_ssfctrlop-no_dialog  = ' '.
     t_ssfctrlop-device     = ' '.
     t_ssfcompop-tdcover    = ' '.
     t_ssfcompop-tdcopies   = '01'.
     t_ssfcompop-tdimmed    = 'X'.

     CALL FUNCTION lf_fm_name
       EXPORTING
         control_parameters = t_ssfctrlop
         output_options     = t_ssfcompop
         user_settings      = ' '
         g_total            = g_total " Valor total
       TABLES
         t_head             = it_head
         t_det              = it_det
       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.
   ENDIF.


Thanks for your time.

0 Kudos

I add the following, because I made a debbug:
When I enter a command such order 00100 shows me the exact number of records:

order 00100
1
2
3

For example the same order 00101 shows the exact number of records:
order 00101
5
6
7

When the two orders income 00100 to 00101 on my internal table records with six, but when viewing the SmartForm, looks like this:

order 00100
1
2
3
4
5
6

order 00101
1
2
3
4
5
6...

0 Kudos

An easy fix would be to add order number as a key to the item table

    LOOP AT gt_result ASSIGNING <fs_datos>.
     CLEAR: st_head, st_det.
     st_head-budat = <fs_datos>-budat.
     st_head-maktx = <fs_datos>-maktx.
     st_head-matnr = <fs_datos>-matnr.
     st_head-aufnr = <fs_datos>-aufnr.
     APPEND st_head TO it_head.

           st_det-aufnr = <fs_datos>-aufnr
     st_det-budat = <fs_datos>-budat.
     st_det-turno = <fs_datos>-turno.
     st_det-charg = <fs_datos>-charg.
     g_total = <fs_datos>-erfmg + g_total.
     APPEND st_det TO it_det.
    ENDLOOP.

In the Item Loop , add the where condition

In the loop to bring detail T_DET INTO ST_DET ---> add the condition "where aufnr = header_table-aufnr"

0 Kudos

Hello Byju Edamana can help me in the following, when income range orders ie 0000111 to 000015, these should be placed in a sheet in order, but does not perform this action.

Hopefully you can guide me, I've seen in other conditions smartforms that placed such

g_tab = 46
OR
g_tab = 91

or

g_tab = 120
....

Please I hope you help me, thanks.

0 Kudos

Currently we have a main/header internal table which loops the order number and based on the order number the item is looped.

So if we need to display them in order 000111->000015 , then sort based on the AUFNR descending for the header internal table.

SORT it_head by AUFNR descending.

Since the it_det loops based on the aufnr of the it_head,it will print accordingly

If the decending sort order needs to be done only for income based orders,then put a logic/condition before sorting.Example

Loop at it_head into st_det where ( AUFNR >= 15 OR AUFNR <= 111 ).

EXIT.

endloop.

if sy-subrc = 0.

SORT it_head by AUFNR descending.

endif.

Hope it helps...