cancel
Showing results for 
Search instead for 
Did you mean: 

How can i create Header and items in SMART FORM

Former Member
0 Kudos

Hi Experts,

How can i create Header and items in SMART FORM in the below driver program.

_Header fields_

SELECT BUKRS BUDAT GJAHR CPUDT USNAM BLART BELNR XBLNR BLDAT WAERS KURSF

FROM BKPF INTO CORRESPONDING FIELDS OF TABLE IT_HEAD WHERE BELNR IN S_BELNR AND BUDAT IN S_BUDAT AND GJAHR EQ S_GJAHR AND BUKRS EQ S_BUKRS AND CPUDT IN S_CPUDT AND USNAM IN S_USNAM.

Item firlds

SELECT BUZEI BSCHL SGTXT SHKZG KOSTL PRCTR WERKS WRBTR HKONT KUNNR ZFBDT FROM BSEG INTO CORRESPONDING FIELDS OF TABLE IT_ITEM

FOR ALL ENTRIES IN IT_HEAD WHERE BELNR = IT_HEAD-BELNR AND GJAHR = IT_HEAD-GJAHR AND BUKRS = IT_HEAD-BUKRS.

LOOP AT IT_HEAD.

MOVE-CORRESPONDING IT_HEAD TO FINAL.

LOOP AT IT_ITEM

WHERE BELNR = IT_HEAD-BELNR.

MOVE-CORRESPONDING IT_ITEM TO FINAL.

ENDLOOP.

ENDLOOP.

Regards,

Sreedhar.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI

In the main window create two loops one for header and another for an item.

In the Header loop create the template drag and drop the fields into the text node and repeat the same process

for the for the item.

Regards,

Sravanthi

Former Member
0 Kudos

Hi Sravanthi,

Header and items are working fine in your logic but it display continuesly. i need one document number have one page or continues when footer ends the another document goes to next page stating with header.

Thanks & Regards,

Sreedhar.

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Sreedhar,

Try it this way: under your main window create a table, in that in main area loop your header table and display the header data in a text, now under your first loop create a nested loop for your item table and maintain the where condition in that, now display the item data:

MAIN WINDOW
  Header
  Main Area
     LOOP1  ( Loop it_head into wa_head)
        ROW1
           CELL1
              TEXT1 ( print header data here)
        LOOP2 ( Loop it_item into wa_item where condition )
           ROW2
              CELL2
                 TEXT2 ( print item data here) 
    
    
  Footer

With luck,

Pritam.

Edited by: Pritam Ghosh on Feb 24, 2009 1:09 PM

Former Member
0 Kudos
Former Member
0 Kudos

Hi:

Nested loop is required

Loop at header

loop at item where item = header-item

endloop

endloop.

Regards

Shashi

Former Member
0 Kudos

for these internal tables you can pass some Identifier for both tables.

in header file : IT_HEAD

IDENT type char10,

BUKRS type BUKRS,

BUDAT type BUDAT, like

in header file :IT_ITEM

IDENT type char10,

BUZEI type BUZEI,

BSCHL type BSCHL, like in item data

you need to fille the IDENT value like

IT_HEAD:

10 -- DE01-- 10.20.2009

20 -- CH01-- 10.20.2009

IT_ITEM

10 -- 1234-- KSCHL value like all records

10 -- 2345-- KSCHL value like all records

10 -- 6783-- KSCHL value like all records

20 -- 3452-- 1KSCHL value like all records

20 -- 4532-- KSCHL value like all records

20 -- 4535-- KSCHL value like all records

in smartform you need to create 2 tables.

or create

LOOP with IT_HEAD

table with IT_HEAD

table with IT_ITEM

and put the condition for each table in DATA tab where condtion like IDENT = IT_HEAD-IDENT

in item table also INDENT = IT_ITEM-INDENT..

Former Member
0 Kudos

I think sravanthi means a nested loop.