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: 

Report

former_member202957
Contributor
0 Kudos

Hi experts,

I have a report it shows the total montly stock of YARN and CHEMICAL. The input fields are montly date and Matnerial number. Depending on the material number it shows the total stock of Yarn and chemical. i have taken two radio button one for yarn and another for CHEMICAL>

if i select yarn all the stock of yarn is shown.and if i select chemical all the chemcial stock is shown.

My requiment is i have to insert all the data which is coming in the internal table to Zstock1 database table for both yarn and chemical.

*THIS IS MY SELECTION SCREEN

PARAMETERS : r1 RADIOBUTTON GROUP g DEFAULT 'X', " YARN

opcase TYPE i DEFAULT 0 ,

opqty LIKE j_1iexcdtl-menge DEFAULT 0,

r2 RADIOBUTTON GROUP g, "CHEMICAL

opqty1 LIKE j_1iexcdtl-menge DEFAULT 0,

opqty2 LIKE j_1iexcdtl-menge DEFAULT 0,

opqty3 LIKE j_1iexcdtl-menge DEFAULT 0,

opqty4 LIKE j_1iexcdtl-menge DEFAULT 0,

opqty5 LIKE j_1iexcdtl-menge DEFAULT 0,

opqty6 LIKE j_1iexcdtl-menge DEFAULT 0,

opqty7 LIKE j_1iexcdtl-menge DEFAULT 0,

opqty8 LIKE j_1iexcdtl-menge DEFAULT 0,

opqty9 LIKE j_1iexcdtl-menge DEFAULT 0,

opqty10 LIKE j_1iexcdtl-menge DEFAULT 0,

opqty11 LIKE j_1iexcdtl-menge DEFAULT 0.

**THIS ARE THE PERFORM STATEMENTS USED TO GET THE DATA

IF r1 = 'X'.

PERFORM production.

PERFORM domestic.

PERFORM export.

PERFORM deemed_export.

*This is the internal table for YARN

LOOP AT it_totstk.

totcases = opcase + it_totstk-pcases.

clcase = totcases - it_totstk-dcases - it_totstk-ecases -

it_totstk-decases .

totqty = opqty + it_totstk-pmenge.

clqty = totqty - it_totstk-dmenge - it_totstk-emenge -

it_totstk-demenge .

FORMAT COLOR 6 INVERSE ON .

WRITE : /2(10) it_totstk-month ,sy-vline, 15(8)

opcase

NO-ZERO ,25(15) opqty NO-ZERO ,sy-vline,42(8) it_totstk-pcases NO-ZERO ,

52(15) it_totstk-pmenge

NO-ZERO,sy-vline,

70(8) totcases NO-ZERO,80(15) totqty NO-ZERO,sy-vline,97(8)

it_totstk-dcases NO-ZERO, 107(15) it_totstk-dmenge NO-ZERO,sy-vline,

125(8) it_totstk-ecases NO-ZERO ,135(15) it_totstk-emenge

NO-ZERO,sy-vline,

152(8) it_totstk-decases NO-ZERO,

162(15) it_totstk-demenge NO-ZERO,sy-vline,180(8) clcase

NO-ZERO,190(15)

clqty NO-ZERO ,sy-vline, 207(15) it_totstk-dexbas NO-ZERO,sy-vline,

225(15) it_totstk-dexbed NO-ZERO,sy-vline,243(15)

it_totstk-decs NO-ZERO,

sy-vline,260(15) it_totstk-dexaddtax1 NO-ZERO,sy-vline.

opcase = clcase.

opqty = clqty.

AT END OF month.

ULINE AT /(276).

ENDAT.

AT LAST.

SUM.

WRITE : /15 'Total:......',42(8) it_totstk-pcases,52(15)

it_totstk-pmenge,sy-vline,

98(8) it_totstk-dcases, 107(15) it_totstk-dmenge,

sy-vline,

125(8) it_totstk-ecases ,135(15) it_totstk-emenge,

sy-vline,152(8) it_totstk-decases,

162(15) it_totstk-demenge,sy-vline,207(15)

it_totstk-dexbas,sy-vline,

225(15) it_totstk-dexbed,sy-vline,243(15) it_totstk-decs

,sy-vline,260(15) it_totstk-dexaddtax1,sy-vline.

ULINE AT /(276).

ENDAT.

FORMAT COLOR OFF.

ENDLOOP.

IF R2 = 'X'.

the internal table for the CHEMICAL is

LOOP AT it_totstk1.

totqty = opqty + it_totstk1-pmenge.

clqty = totqty - it_totstk1-defkimg - it_totstk1-sfkimg .

WRITE : /2(10) it_totstk1-month NO-ZERO ,sy-vline,

15(15) opqty NO-ZERO,sy-vline,32(15) it_totstk1-pmenge

NO-ZERO,sy-vline,

50(15) totqty NO-ZERO,sy-vline,67(15) it_totstk1-sfkimg

NO-ZERO,sy-vline,

85(15) it_totstk1-defkimg NO-ZERO,sy-vline,

102(15) clqty NO-ZERO ,sy-vline,

120(15) it_totstk1-sexbas NO-ZERO,sy-vline,

137(15) it_totstk1-sexbed NO-ZERO,sy-vline,

155(15) it_totstk1-secs NO-ZERO,sy-vline,

172(15) it_totstk1-sexaddtax1 NO-ZERO,sy-vline,

190(15) it_totstk1-brtwr NO-ZERO,sy-vline,

210(15) it_totstk1-cpmenge NO-ZERO ,sy-vline,

227(15) it_totstk1-cpexbas NO-ZERO,sy-vline,

245(15) it_totstk1-cpimenge NO-ZERO,sy-vline,

262(15) it_totstk1-cpiexbas NO-ZERO,sy-vline.

opqty = clqty.

AT END OF month.

ULINE AT /(300).

ENDAT.

AT LAST.

SUM.

temptot = tempop + it_totstk1-pmenge.

tempcl = temptot - it_totstk1-sfkimg - it_totstk1-defkimg.

FORMAT COLOR 5.

WRITE : /2 'Total:..',15(15) tempop NO-ZERO,sy-vline,

32(15) it_totstk1-pmenge NO-ZERO,sy-vline,

50(15) temptot ,sy-vline NO-ZERO,

67(15) it_totstk1-sfkimg NO-ZERO,sy-vline,

85(15) it_totstk1-defkimg NO-ZERO,sy-vline,

102(15) tempcl NO-ZERO,sy-vline,

120(15) it_totstk1-sexbas NO-ZERO,sy-vline,

137(15) it_totstk1-sexbed NO-ZERO,sy-vline,

155(15) it_totstk1-secs NO-ZERO,sy-vline,

172(15) it_totstk1-sexaddtax1 NO-ZERO,sy-vline,

190(15) it_totstk1-brtwr NO-ZERO,sy-vline,

210(15) it_totstk1-cpmenge NO-ZERO,sy-vline,

227(15) it_totstk1-cpexbas NO-ZERO,sy-vline,

245(15) it_totstk1-cpimenge NO-ZERO,sy-vline,

262(15) it_totstk1-cpiexbas NO-ZERO,sy-vline.

FORMAT COLOR OFF.

ULINE AT /(300).

CLEAR : opqty,clqty,totqty,tempop,tempcl,temptot.

ENDAT.

ENDLOOP.

CLEAR : it_sales[],it_sales1[],it_totstk1[],

it_prod[],it_prod1[],it_corder[],it_corder1[].

CLEAR : it_sales,it_sales1,it_totstk1,

it_prod,it_prod1,it_corder,it_corder1.

now i have to insert this internal table values which are coming into ZSTOCK1 database table

the structure of zstock1 is shown below.

ZSTOCK1

Stock Table for Chemicals and Yarn

1.MANDT Client

2.WERKS Plant

3.LGORT Issue Storage Location

4.SPART Division

5.BWART Movement Type (Inventory Management)

5.MATNR Material Number

6.BUDAT Posting Date in the Document

7.OPCS Opening Cases

8.OPQT Operation Quantity

9.GEWEI Weight Unit

10.PRDCS Production Case

11.PRDQT Production Quantity

12.DOMCS Dom Cases

13.DOMQT Production Quantity

14.EXPCS Exp Cases

15.EXPQT Export Quantity

16.DEEMCS Deem Cases

17.DEEMQT Deemed Quantity

18.CAPCS Cap Cases

19.CAPQT Cap Qty

20.CAPINTCS Cap Initail CS

21.CAPINTQT Cap Initial Qty

22.CLCS Closing CS

23.CLQT Closed Quantity

24.EXCUR Currency

25.EXBAS Excise Duty Base Amount

26.BED Basic Excise Duty

27.CESS ECS Value

28.SECESS Additional Tax1 value

IF I select YARN the yarn data should be inserted in database and if i select chemcal the chemical details from the internal table should be inserted in database table

plaease help me its an urgent requiremnt to me.....

<b>useful answers are rewarded</b>

thanks & Regards,

K.Sunil kumar.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Sunil,

You can use If condition for your requirement and you need two separate internal tables.

Example to say R1 and R2 are the two radio buttons, Ztable1 for Yarn and Ztable2 is for Chemical and Itab1 for Yarn and Itab2 for Chemical.

In this case you have to write the Condition like,

If R1 eq X.

Loop at itab1.

Ztable1-field1 = Itab1-field1.

Insert Ztable1.

else if R2 Eq X.

Loop at itab2.

Ztable2-field1 = Itab2-field1.

Insert Ztable2.

Endif.

Thanks.

5 REPLIES 5

varma_narayana
Active Contributor
0 Kudos

Hi Sunil..

Declare the Internal table with the Same structure as the DB table ZSTOCK1 .

DATA: IT_STOCK TYPE TABLE OF ZSTOCK1 WITH HEADER LINE.

then After filling the Data in this internal table it can be inserted into DB table:

INSERT ZSTOCK1 FROM TABLE IT_STOCK ACCEPTING DUPLICATE KEYS.

write:/ 'No of recs inserted = ', SY-DBCNT.

<b>reward if Helpful.</b>

0 Kudos

Hi varma,

Thankx for ur quick reply.

The internal table fields are taken from differnt tables and its structure is differnt as shown below.

DATA : BEGIN OF it_totstk OCCURS 0,

CLIENT TYPE SY-MANDT,

month LIKE wb2_v_mkpf_mseg2-budat,

pdat LIKE wb2_v_mkpf_mseg2-budat,

pmenge LIKE wb2_v_mkpf_mseg2-menge_i,

matnr LIKE j_1iexcdtl-matnr,

ddat LIKE j_1iexchdr-exdat,

dmenge LIKE j_1iexcdtl-menge,

dexbas LIKE j_1iexcdtl-exbas,

dexbed LIKE j_1iexcdtl-exbed,

dexaddtax1 LIKE j_1iexcdtl-exaddtax1,

decs LIKE j_1iexcdtl-ecs,

emenge LIKE lips-lfimg,

edat LIKE likp-wadat,

dedat LIKE vbrk-fkdat,

demenge LIKE vbrp-fklmg,

pcases TYPE i,

ecases TYPE i,

dcases TYPE i,

decases TYPE i,

END OF it_totstk.

                                • IT_TOTSTK1 INTERNAL TABLE******

DATA : BEGIN OF it_totstk1 OCCURS 0,

month LIKE wb2_v_mkpf_mseg2-budat,

pdat LIKE wb2_v_mkpf_mseg2-budat,

matnr LIKE j_1iexcdtl-matnr,

pmenge LIKE wb2_v_mkpf_mseg2-menge_i,

sdat LIKE wb2_v_vbrk_vbrp2-fkdat,

smatnr LIKE j_1iexcdtl-matnr,

sfkimg LIKE wb2_v_vbrk_vbrp2-fkimg_i,

swerks LIKE wb2_v_vbrk_vbrp2-werks_i,

sfkart LIKE wb2_v_vbrk_vbrp2-fkart,

sexbas LIKE j_1iexcdtl-exbas,

sexbed LIKE j_1iexcdtl-exbed,

sexaddtax1 LIKE j_1iexcdtl-exaddtax1,

secs LIKE j_1iexcdtl-ecs,

spart LIKE mara-spart,

dedat LIKE vbrk-fkdat,

defkimg LIKE vbrp-fklmg,

dematnr LIKE j_1iexcdtl-matnr,

brtwr LIKE wb2_v_vbrk_vbrp2-brtwr_i,

cpdat LIKE j_1iexchdr-exdat,

cpmatnr LIKE j_1iexcdtl-matnr,

cpmenge LIKE j_1iexcdtl-menge,

cpexbas LIKE j_1iexcdtl-exbas,

cpidat LIKE j_1iexchdr-exdat,

cpimatnr LIKE j_1iexcdtl-matnr,

cpimenge LIKE j_1iexcdtl-menge,

cpiexbas LIKE j_1iexcdtl-exbas,

END OF it_totstk1.

so what i done is i have anothe internal table ITAB with the structure of Zstock1 .

Data: begin of itab occurs 0.

include structure zstock1.

data: end of itab.

And written the following condition after the write statement of both YARN and chemical.

for YARN the internal table is it_stotstk i have send the corresponding fields of it_totstk into itab and written insert statement using internal table itab.

loop at it_totstk .

Move-corresponding it_totstk to itab.

append itab.

endloop.

loop at itab.

itab-mandt = sy-mandt.

insert into zstock1 client specified values itab.

COMMIT WORK.

endloop.

And for Chemical it_totstk1 is the internal table .

loop at it_totstk .

Move-corresponding it_totstk to itab.

append itab.

endloop.

loop at itab.

itab-mandt = sy-mandt.

*modify itab.

insert into zstock1 client specified values itab.

COMMIT WORK.

endloop.

But after executing the report the values are not inserting in the database so what should i do now.? please help me..

thankx and Regards,

k sunil kumar

0 Kudos

hi Sunil..

As i mentioned in the Previous post you must Declare the Internal table with the Same structure as the Db table ZSTOCK1 .

Then move the Records from your internal table it_totstk to this itab using

LOOP AT it_totstk .

<< MOVE ALL THE FIELDS OF it_totstk TO ITAB .>>

APPEND ITAB.

ENDLOOP.

Then:

insert Zstock1 from table ITAB ACCEPTING DUPLICATE KEYS.

Note :1) Don't use the CLIENT SPECIFIED option in the INSERT STATEMENT

2) Don't INSERT The Records inside the LOOP .. it will be slow.

REWARD IF HELPFUL.

0 Kudos

hi varma,

i am not getting the values in internal table only in debgging i hv seen that only client name is showin in internal table and only one record with client is inserting in the database table zstock.

i am not understanding the problem .

please help me its un urgent.

regards,

sunil kumar

Former Member
0 Kudos

Hi Sunil,

You can use If condition for your requirement and you need two separate internal tables.

Example to say R1 and R2 are the two radio buttons, Ztable1 for Yarn and Ztable2 is for Chemical and Itab1 for Yarn and Itab2 for Chemical.

In this case you have to write the Condition like,

If R1 eq X.

Loop at itab1.

Ztable1-field1 = Itab1-field1.

Insert Ztable1.

else if R2 Eq X.

Loop at itab2.

Ztable2-field1 = Itab2-field1.

Insert Ztable2.

Endif.

Thanks.