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: 

Logic needed

former_member1349771
Participant
0 Kudos

I have a report in which most of condition types hard coded in the program and every time required modification on creation of new condition type.

I wish to make this report flexi to show the values of all condition type of selected records.

Wht steps should be taken to determine runtime recorde to be written as output.

Please Guide

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Select all the condintions from the database......and use the dynamic internal table to display the output..........

Regards,

Vamshidhar .

8 REPLIES 8

Former Member
0 Kudos

hi there....

kindly clarify ur qstn or put in the code....

do reward ....

0 Kudos

case i_konv-kschl.

when 'JEX2'. "Basic Excise Duty

itab1-kawrt = i_konv-kawrt.

when 'JHAC'. "Handling Charges

itab1-handling = i_konv-kwert.

when 'PR00'. "Basic Price

itab1-rate = i_konv-kbetr.

when 'ZGAC'. "Admin charges

itab1-admin = i_konv-kwert.

when 'JAED'. "Addl.Excise Duty

itab1-kwert = i_konv-kwert.

when 'JCES'. "Cess

itab1-cess = i_konv-kwert.

when 'JECS'. "Education Cess

itab1-eces = i_konv-kwert.

when 'JIN2' or 'JIN1' or 'JIN3' or 'JIN4' or 'JIN5'

or 'JIN6' or 'JIN7' or 'JIN8'. "SALES TAX

itab1-saltx = itab1-saltx + i_konv-kwert.

when 'ZDMO'. "Deferred Tax on Molasses

itab1-zdmo = i_konv-kwert.

when 'JING'. "Entry tax

itab1-entry = i_konv-kwert.

when 'JIUP'. "LSTax

itab1-jiup = i_konv-kwert.

when 'ZVPD'. "pRICE dISCOUNT

itab1-zvpd = i_konv-kwert.

when 'ZCDR'. "CASH DISCOUNT

itab1-zcdr = i_konv-kwert.

when 'ZPDF'. "PRICE DIFF DISCOUNT

itab1-zpdf = i_konv-kwert.

when 'ZCDC'. "CASH SP DISCOUNT

itab1-zcdc = i_konv-kwert.

when 'ZCDD'. "CASH DISCOUNT (COMPOUNDING)

itab1-zcdd = i_konv-kwert.

when 'ZINT'. "INTEREST

itab1-zint = i_konv-kwert.

when 'ZFCD'. "CASH DISCOUNT

itab1-zfcd = i_konv-kwert.

when 'ZFGD'. "GENERAL DISCOUNT

itab1-zfgd = i_konv-kwert.

when 'ZDTX'. "DEVELOPMENT TAX

itab1-zdtx = i_konv-kwert.

when 'ZDTA'. "DEVELOPMENT TAX

itab1-zdta = i_konv-kwert.

when 'ZFRT'. "FREIGHT SUBSIDY (COMPOUNDING)

itab1-zfrt = i_konv-kwert.

when 'ZFSP'. "FREIGHT SUBSIDY (CMPDNG)

itab1-zfsp = i_konv-kwert.

when 'ZMRP'. "TRADING MARGIN

itab1-zmrp = i_konv-kwert.

when 'ZFRF'. "FREIGHT SUBSIDY

itab1-zfrf = i_konv-kwert.

when 'ZTRS'. "TRADE DISCOUNT (SBM)

itab1-ztrs = i_konv-kwert.

when 'ZCDS'. "CASH DISCOUNT(SBM)

itab1-zcds = i_konv-kwert.

when 'ZTCC'. "TC CESS (SBM)

itab1-ztcc = i_konv-kwert.

when 'PR11'. "Price Manual

itab1-rate = i_konv-kbetr.

itab1-pr11 = itab1-fkimg * itab1-rate.

when 'ZDSP'. "Customer Discount%

itab1-zdsp = i_konv-kwert.

when 'ZDSQ'. "Price Manual

itab1-zdsq = i_konv-kwert.

when 'JINK'. "Works Cont(VAT) Tax

itab1-jink = i_konv-kwert.

when 'JINM'. "Turnover Tax

itab1-jinm = i_konv-kwert.

when 'ZFRB '. "Freight Lump sum

itab1-zfrb = i_konv-kwert.

when 'ZILN'. "Installation

itab1-ziln = i_konv-kwert.

when 'ZINP'. "Insurance Charges(%)

itab1-zinp = i_konv-kwert.

when 'ZSTI '. "Service Tax ? Fenesta

itab1-zsti = i_konv-kwert.

when 'ZECI'. "ECESS on Ser Tax

itab1-zeci = i_konv-kwert.

when 'ZCRQ'.

itab1-zcrq = i_konv-kwert.

when 'ZCRG'.

itab1-zcrg = i_konv-kwert.

when 'ZDIF'.

itab1-zdif = i_konv-kwert.

when 'ZCPQ'.

itab1-zcpq = i_konv-kwert.

when 'ZCPD'.

itab1-zcpd = i_konv-kwert.

when 'ZCPT'.

itab1-zcpt = i_konv-kwert.

when 'ZSIR'.

itab1-zsir = i_konv-kwert.

when 'ZCDT'.

itab1-zcdt = i_konv-kwert.

when 'ZCRS'.

itab1-zcrs = i_konv-kwert.

when 'ZSAD'.

itab1-zsad = i_konv-kwert.

when 'ZSIN'.

itab1-zsin = i_konv-kwert.

when 'ZFRM'.

itab1-zfrm = i_konv-kwert.

when 'ZABC'.

itab1-zabc = i_konv-kwert.

when 'ZGBC'.

itab1-zgbc = i_konv-kwert.

when 'ZEPI'.

itab1-zepi = i_konv-kwert.

when 'ZFDI'.

itab1-zfdi = i_konv-kwert.

when 'JA1X'.

ITAB1-HECESS = i_konv-kwert.

WHEN 'ZSHE'.

ITAB1-SHECESS = i_konv-kwert.

when 'ZAVT'. " Additional VAT Tax (ZAVT)

itab1-zAVT = i_konv-kwert.

when 'ZSTB'. " ZSTB

itab1-ZSTB = i_konv-kwert.

when 'ZECB'. " ZECB

itab1-ZECB = i_konv-kwert.

when 'ZSHB'. " ZSHB

itab1-ZSHB = i_konv-kwert.

endcase.

i wish to write these dynamically instead of hard code

Former Member
0 Kudos

Hi,

You can select it, from the condition table based on the certain conditions you want and populate it in a select option internal table structure, so that you can use that in condition checking if condt in s_cont. It would be helpful if you elaborate your question

Reward if useful.

Thanks,

Muthu.

0 Kudos

My report is for Daily Godown dispatches with condition valu details .

I have ceratain billing documents now i want tht whatever conditions are matained for billing time should auotmaticaaly be displayed in my report insted of hard cade as above.

Hope this is clarify my problem.

Former Member
0 Kudos

Select all the condintions from the database......and use the dynamic internal table to display the output..........

Regards,

Vamshidhar .

0 Kudos

Hello Vamshidhar,

How to use dynamic internal table to display the output.

Thanks

Edited by: ABHUT on May 23, 2008 11:43 AM

Former Member
0 Kudos

hi

one way is

using FM

CALL FUNCTION READ_TEXT

Exporting

cleint = sy_mandt

id = threadid

lang =

name

object

tables

lines = it_lines.

for ex tid is ZSIG tdname is 9900 and tdobject is ZMM.

from the is u get the all the condtions and their values.

other way is

all the condtions are stored KONV table,

u get the values u should add the condtions in report.

without add condition types how to get values for that condition type.

sample code

start-of-selection.

select vbrk~fkart

vbrp~matnr

vbrp~aubel

vbrk~vbeln

vbrk~vbtyp

vbrk~fkdat

vbrp~posnr

vbrp~vgbel

vbrp~vgpos

vbrp~fkimg

vbrp~netwr

vbrp~lgort

vbrp~cuobj

vbrk~knumv

vbrk~erdat

into table int_vbrk

from ( ( vbrk inner join vbrp

on vbrk~vbeln = vbrp~vbeln )

inner join mara

on vbrp~matnr = mara~matnr )

where vbrk~fkdat in s_fkdat

and mara~mtart = 'FERT'.

if not int_vbrk[] is initial.

select ser01~lief_nr

ser01~posnr

objk~equnr

objk~sernr

into table int_sernr

from ser01 inner join objk on ser01~obknr = objk~obknr

for all entries in int_vbrk where

ser01~lief_nr = int_vbrk-vgbel and

ser01~posnr = int_vbrk-vgpos .

endif.

if not int_sernr[] is initial.

select ser05~ppaufnr

ser05~ppposnr

objk~sernr

into table int_aufnr

from ser05 inner join objk on ser05~obknr = objk~obknr

for all entries in int_sernr where

objk~sernr = int_sernr-sernr.

endif.

loop at int_aufnr.

select single *

from aufk where aufnr = int_aufnr-ppaufnr.

"and auart in ordty.

if sy-subrc <> 0.

delete int_aufnr where ppaufnr = int_aufnr-ppaufnr.

else.

int_aufnr-auart = aufk-auart.

modify int_aufnr transporting auart.

endif.

endloop.

loop at int_aufnr.

concatenate 'OR' int_aufnr-ppaufnr into int_aufnr-order.

modify int_aufnr.

endloop.

describe table int_aufnr lines sy-tabix .

if sy-tabix > 0.

select objnr from

auak into corresponding fields of table itab3

for all entries in int_aufnr

where objnr = int_aufnr-order

and stflg = space

and stokz = space.

endif.

if not int_vbrk[] is initial.

select knumv zaehk kbetr kschl kwert

from konv

into corresponding fields of table it_konv

for all entries in int_vbrk

where knumv = int_vbrk-knumv

and kschl in ('VA00',

'ZMD1',

'ZV00',

'ZED',

'ZSED',

'ZCES',

'KF00',

'ZD00',

'ZDIF',

'Z007',

'Z004',

'ZTD3',

'ZTD2',

'ZREB',

'ZCM5',

'ZV01',

'ZTD1',

'ZP07',

'ZDDF',

'Z009',

'ZV02',

'ZVAS',

'ZMDS',

'ZSTD',

'ZNCD',

'ZV03',

'ZV04',

'ZV05',

'ZTD1',

'ZTD4',

'ZTD5',

'ZTD6',

'ZTD7',

'ZTD8',

*********************Start on EDS and SZ398R - 04/03/2008,05/03/2008

'ZTD9','ZTDI','ZTDN','ZTDR','ZTSP',

'ZSP','ZSPE','ZSCR','ZPCE','ZPAE',

'ZEDC','ZEDU','ZF00','ZED2','ZP06',

'SKTO','ZNDP','SKTV','Z001','ZADB',

'PR00','UTXJ','JMOD','JEX2','JAED',

'JEXA','JSED','JEXS','JNED','JEXN',

'JCES','JCED','JECS','JECX','JA1X',

'JA1Y','JIN6','JIN7','ZDIF').

*********************End of EDS and SZ398R - 04/03/2008,05/03/2008

endif.

----


  • END OF SELECTION

----


end-of-selection.

*******Start on EDS and SZ398R - 05/03/2008

v_date = '20080101' .

*******End of EDS and SZ398R - 05/03/2008

  • set pf-status 'ABCD'.

loop at int_vbrk.

flag = 0.

clear int_sernr.

read table int_sernr with key

lief_nr = int_vbrk-vgbel

posnr = int_vbrk-vgpos .

clear int_aufnr.

read table int_aufnr with key

sernr = int_sernr-sernr.

clear itab3.

clear settle.

read table itab3 with key objnr = int_aufnr-order.

if sy-subrc <> 0.

loop at int_aufnr where sernr = int_sernr-sernr.

clear itab3.

read table itab3 with key objnr = int_aufnr-order.

if sy-subrc eq 0.

settle = 'X'.

exit.

endif.

endloop.

if sy-subrc ne 0.

delete int_vbrk where vgbel = int_vbrk-vgbel

and vgpos = int_vbrk-vgpos.

clear int_vbrk.

flag = 1.

endif.

else.

settle = 'X'.

endif.

if flag = 0.

clear itab.

move-corresponding int_vbrk to itab.

select single * from vbrk where vbeln = itab-vbeln.

select single * from kna1 where kunnr = vbrk-kunag.

itab-delc = kna1-kunnr.

itab-deln = kna1-name1.

if int_vbrk-vbtyp = 'M' or int_vbrk-vbtyp = 'S'.

itab-sold = 1.

elseif int_vbrk-vbtyp = 'N' or int_vbrk-vbtyp = 'O'.

itab-sold = -1.

endif.

select single *

from ausp

where mafid = 'O '

and klart = '002 ' " '002' For Equipment

and objek = int_sernr-equnr.

if ausp-atinn eq 4.

itab-atwrt = ausp-atwrt.

endif.

itab-sernr = int_sernr-sernr.

itab-ppaufnr = int_aufnr-ppaufnr.

itab-ppposnr = int_aufnr-ppposnr.

itab-auart = int_aufnr-auart.

loop at it_konv where knumv = int_vbrk-knumv.

case it_konv-kschl.

when 'VA00'.

*

itab-va00 = itab-va00 + it_konv-kwert.

*

when 'ZVAS'.

*

itab-va00 = itab-va00 + it_konv-kwert.

*

when 'ZMD1'.

*

itab-zmd1 = itab-zmd1 + it_konv-kwert.

*

when 'ZMDS'.

*

itab-zmd1 = itab-zmd1 + it_konv-kwert.

*

when 'ZV00'.

itab-zv00 = itab-zv00 + it_konv-kwert.

******************************Start on +EDS and SZ398R - 04/03/2008

*Basic Excise Duty Add conditions ZED1 ZEDB ZEXD JMOD JEX2'

when 'ZED' or 'ZED1' or'ZEDB' or 'ZEXD' or 'JMOD' or 'JEX2'.

itab-zed = itab-zed + it_konv-kwert.

*Special Excise Duty Add conditions JSED JEXS ZEDS

when 'ZSED' or 'JSED' or 'JEXS' or 'ZEDS'.

itab-zsed = itab-zsed + it_konv-kwert.

*Cess on Excise Duty Add conditions JCES JCED ZPCE.

when 'ZCES' or 'JCES' or 'JCED' OR 'ZPCE'.

itab-zces = itab-zces + it_konv-kwert.

********************************End of +EDS and SZ398R - 04/03/2008

when 'KF00'.

itab-kf00 = itab-kf00 + it_konv-kwert.

when 'ZD00'.

itab-kf00 = itab-kf00 + it_konv-kwert.

when 'ZDIF'.

itab-zdif = itab-zdif + it_konv-kwert.

when 'Z007'.

itab-z007 = itab-z007 + it_konv-kwert.

when 'Z004'.

itab-z007 = itab-z007 + it_konv-kwert.

when 'ZREB'.

itab-zreb = itab-zreb + it_konv-kwert.

when 'ZCM5'.

itab-zcm5 = itab-zcm5 + it_konv-kwert.

when 'ZV01'.

itab-zv01 = itab-zv01 + it_konv-kwert.

when 'ZTDI'.

itab-ztdi = itab-ztdi + it_konv-kwert.

when 'ZTD2'.

itab-ztd2 = itab-ztd2 + it_konv-kwert.

when 'ZTD3'.

itab-ztd3 = itab-ztd3 + it_konv-kwert.

when 'ZP07'.

itab-zp07 = itab-zp07 + it_konv-kwert.

when 'ZDDF'.

itab-zddf = itab-zddf + it_konv-kwert.

when 'Z009'.

itab-z009 = itab-z009 + it_konv-kwert.

when 'ZV02'.

itab-zv02 = itab-zv02 + it_konv-kwert.

*******************************Start on EDS and SZ398R - 04/03/2008

*Additional Excise Duty Add conditions JAED JEXA ZED2'

when 'ZNCD' or 'JAED' or 'JEXA' or 'ZED2'.

itab-zncd = itab-zncd + it_konv-kwert.

*New condtions added start

*National Calamity and Contingency Duty.

when 'ZNCT' or 'JNED' or 'JEXN'.

itab-znccd = itab-znccd + it_konv-kwert.

*Education Cess

when 'JECS' or 'JECX' or 'ZPAE' or 'ZEDC' or 'ZEDU'.

itab-zedu = itab-zedu + it_konv-kwert.

*Higher and Sec. Education Cess

when 'JA1X' or 'JA1Y'.

itab-zhsedu = itab-zhsedu + it_konv-kwert.

*New condtions added end

********************************End of EDS and SZ398R - 04/03/2008

when 'ZV03'.

itab-zv03 = itab-zv03 + it_konv-kwert.

when 'ZV04'.

itab-zv04 = itab-zv04 + it_konv-kwert.

when 'ZV05'.

itab-zv05 = itab-zv05 + it_konv-kwert.

when 'ZTD1'.

itab-ztd1 = itab-ztd1 + it_konv-kwert.

when 'ZTD4'.

itab-ztd4 = itab-ztd4 + it_konv-kwert.

when 'ZTD5'.

itab-ztd5 = itab-ztd5 + it_konv-kwert.

when 'ZTD6'.

itab-ztd6 = itab-ztd6 + it_konv-kwert.

when 'ZTD7'.

itab-ztd7 = itab-ztd7 + it_konv-kwert.

when 'ZTD8'.

itab-ztd8 = itab-ztd8 + it_konv-kwert.

when 'ZSTD'.

itab-zstd = itab-zstd + it_konv-kwert.

********************Start on EDS and SZ398R - 05/03/2008

*New condtions added start

when 'ZTD9'.

itab-ztd9 = itab-ztd9 + it_konv-kwert.

*Trade Discount New.

when 'ZTDN'.

itab-ztdn = itab-ztdn + it_konv-kwert.

  • Cash Discount

when 'SKTO' OR 'SKTV'.

itab-zcd = itab-zcd + it_konv-kwert.

  • CST Discount

when 'ZDIP'.

itab-zcstd = itab-zcstd + it_konv-kwert.

  • Adok Discount

when 'ZDIK'.

itab-zad = itab-zad + it_konv-kwert.

  • Adhoc Discount.

when 'ZDOK'.

itab-zad1 = itab-zad1 + it_konv-kwert.

  • Test Drive Discount

when 'ZTDR'.

itab-ztdd = itab-ztdd + it_konv-kwert.

  • Special Trade Discount.

when 'ZTSP'.

itab-zstd1 = itab-ztd1 + it_konv-kwert.

*New condtions added end

***********************End of EDS and SZ398R - 05/03/2008

endcase.

endloop.

Former Member
0 Kudos

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

  • FIELD SYMBOLS

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

FIELD-SYMBOLS:

<fs_disp_data>, " Field string for dyn. table

<fs_final_total>, " Field string for finaldata

<fs_fldval> TYPE ANY, " Dynamic field value

<i_disp_data> TYPE STANDARD TABLE. " Dynamic Table

*& Declaretions..

DATA:

i_fcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,

i_fcat2 TYPE lvc_t_fcat WITH HEADER LINE.

in I_CONT get all the selected conditions..

IF i_cont[] IS NOT INITIAL.

  • To prepare Field catalog

PERFORM fill_field_catalog.

  • To prepare dynamic internal table

PERFORM prepare_dynamic_table.

  • Subroutine to fill dynamic internal table

PERFORM fill_dynamictable.

ENDIF.

FORM fill_field_catalog.

DATA:

f_loc TYPE string, " Location

f_field TYPE string, " Dynamic field

f_index(2) TYPE c. " index value

LOOP AT i_cont INTO fs_cont.

MOVE: fs_cont-atx(colum text-conditon name ) TO f_loc,

sy-tabix TO f_index.

CONCATENATE 'LOC_' f_index INTO f_field.

  • To fill the field catalog for every location.

PERFORM fill_field_cat

USING:

f_field 'INT4' f_loc 11.

ENDLOOP.

ENDFORM. " F2400_fill_field_catalog.

FORM fill_field_cat USING p_fieldname TYPE string

p_dattyp TYPE string

p_seltext TYPE string

p_outputlen TYPE any.

i_fcat-fieldname = p_fieldname.

i_fcat-datatype = p_dattyp.

i_fcat-seltext_l = p_seltext.

i_fcat-outputlen = p_outputlen.

IF i_fcat-fieldname EQ 'ORD'.

i_fcat-no_out = 'X'.

ENDIF.

APPEND i_fcat.

CLEAR i_fcat.

ENDFORM. " FORM f2410_fill_field_cat

FORM prepare_dynamic_table.

LOOP AT i_fcat.

MOVE:

i_fcat-fieldname TO i_fcat2-fieldname,

i_fcat-ref_tabname TO i_fcat2-ref_table,

i_fcat-outputlen TO i_fcat2-outputlen,

i_fcat-seltext_s TO i_fcat2-scrtext_s.

APPEND i_fcat2 .

CLEAR i_fcat2.

ENDLOOP. " LOOP AT i_fcat.

  • To create dynamic internal table for the fieldcatalog

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = i_fcat2[]

IMPORTING

ep_table = w_data

EXCEPTIONS

generate_subpool_dir_full = 1

OTHERS = 2.

IF sy-subrc NE 0.

  • sy-subrc check is not required.

ENDIF. " IF sy-subrc NE 0.

  • Assign the internal table to <i_disp_data>.

ASSIGN w_data->* TO <i_disp_data>.

  • Create structure of line type <i_disp_data>

CREATE DATA w_type LIKE LINE OF <i_disp_data>.

CREATE DATA w_final LIKE LINE OF <i_disp_data>.

  • Assign structure to <fs_disp_data>

ASSIGN w_type->* TO <fs_disp_data>.

ASSIGN w_final->* TO <fs_final_total>.

ENDFORM. " prepare_dynamic...

FORM fill_dynamictable.

DATA:

f_index TYPE sy-index, " Index value

f_total TYPE covp-wkgbtr. " Over all value

DATA: lv_index TYPE i.

DATA: lv_total TYPE i.

DATA: lv_rows TYPE i.

SORT i_data BY ord eg esg.

DESCRIBE TABLE i_fcat LINES lv_rows.

LOOP AT i_data INTO fs_data.

READ TABLE i_cont INTO fs_cont WITH KEY ansvh = fs_data-ansvh.

IF sy-subrc EQ 0.

CLEAR lv_index.

lv_index = sy-tabix.

ASSIGN COMPONENT lv_index OF STRUCTURE <fs_disp_data>

TO <fs_fldval>.

MOVE fs_data-index TO <fs_fldval>.

ENDIF.

AT END OF ur key field.

ASSIGN COMPONENT lv_rows OF STRUCTURE <fs_disp_data>

TO <fs_fldval>.

APPEND <fs_disp_data> TO <i_disp_data>.

CLEAR <fs_disp_data>.

CLEAR lv_index.

CLEAR lv_total.

ENDAT.

ENDLOOP.

ENDFORM. " fill_dynamictable.

use the <i_disp_data> table to display in ALV list

Regards,

Vamshidhar .