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: 

How to subtract two fields

Former Member
0 Kudos

Hi,

All,

I want to calculate balence quota. by usingdifference of two fields. ITAB-ANZHL and ITAB-ABWTG .

. i have taken a variable A FOR balence Quota. in itab i have defined A TYPE C, in field catalog i have written

'A' 'ITAB' 'BALENCE QUOTA'. so how need to perform coding for calcualte balence quota.

A is for balence quota.

Thanks,

Regards,

Saurabh

9 REPLIES 9

Former Member
0 Kudos

Hi,

use the below code it will help you to subtract.

You have declared the filed A to store the result for subtract the fields.

LOOP AT ITAB INTO WA.

A = WA-ANZHL - WA-ABWTG.

So the result get stored in A.

Do the append WA to ITAB.

Clear WA.

ENDLOOP>

0 Kudos

Hi,

All,

when i am executing my program then i am getting error a line of "ITAB'' and "WA" are not mutually convertiable. in a Unicode

program, "ITAB" must have the same structure layout as "WA" irrespective of the length of a unicode character. Unicode character.

Please provide me soloution,

Thanks,

Regards,

Saurabh

0 Kudos

declare like this...

TYPES : BEGIN OF TY_TAB,

PERNR LIKE PA2006-PERNR,

KTART LIKE PA2006-KTART,

KTEXT LIKE T556B-KTEXT,

ANZHL LIKE PA2006-ANZHL, " Quota number

BEGDA LIKE PA2006-BEGDA,

ENDDA LIKE PA2006-ENDDA,

KVERB LIKE PA2006-KVERB,

AWART LIKE PA2001-AWART,

ATEXT LIKE T554T-ATEXT,

STDAZ LIKE PA2001-STDAZ,

ABWTG LIKE PA2001-ABWTG,

KALTG LIKE PA2001-KALTG,

A TYPE I,

END OF TY_TAB.

DATA: ITAB TYPE STANDARD TABLE OF TY_TAB,

WA LIKE LINE OF ITAB.

former_member233090
Active Contributor
0 Kudos

Hi mishra,

Can you paste the code here,

you can directly subtract two fields taken them in one work area.

cheers,

bhavana

0 Kudos

DATA : BEGIN OF ITAB OCCURS 0 ,

PERNR LIKE PA2006-PERNR,

KTART LIKE PA2006-KTART,

KTEXT LIKE T556B-KTEXT,

ANZHL LIKE PA2006-ANZHL, " Quota number

BEGDA LIKE PA2006-BEGDA,

ENDDA LIKE PA2006-ENDDA,

KVERB LIKE PA2006-KVERB,

AWART LIKE PA2001-AWART,

ATEXT LIKE T554T-ATEXT,

STDAZ LIKE PA2001-STDAZ,

ABWTG LIKE PA2001-ABWTG,

KALTG LIKE PA2001-KALTG,

A TYPE I,

END OF ITAB.

DATA : B TYPE I.

SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS : PERNR FOR PA2006-PERNR NO-EXTENSION NO INTERVALS .

SELECT-OPTIONS : BEGDA FOR PA2006-BEGDA NO-EXTENSION NO INTERVALS.

SELECT-OPTIONS : ENDDA FOR PA2006-ENDDA NO-EXTENSION NO INTERVALS.

SELECTION-SCREEN : END OF BLOCK B1.

'PERNR' 'ITAB' 'Personnel no',

*'GJAHR' 'ITAB' 'Year',

'KTART' 'ITAB' 'Absence Quota type',

'KTEXT' 'ITAB' 'Text',

'ANZHL' 'ITAB' 'Quota Number',

'KVERB' 'ITAB' 'Quota Deduction',

'BEGDA' 'ITAB' 'Start',

'ENDDA' 'ITAB' 'T0',

'AWART' 'ITAB' 'Absence Quota Type',

'ATEXT' 'ITAB' 'Text',

'STDAZ' 'ITAB' 'Absence hours',

'ABWTG' 'ITAB' 'Absence Days',

'KALTG' 'ITAB' 'Calender Days',

'ABWTG' 'ITAB' 'Quota Used',

'A' 'ITAB' 'Balence Quota'.

SELECT M1~PERNR

M1~KTART

M1~ANZHL

M1~BEGDA

M1~ENDDA

M1~KVERB

M2~AWART

M2~STDAZ

M2~ABWTG

M2~KALTG INTO CORRESPONDING FIELDS OF TABLE ITAB

FROM PA2006 AS M1

INNER JOIN PA2001 AS M2

ON M1PERNR = M2PERNR

  • AND M1BEGDA = M2BEGDA

    • AND M1ENDDA = M2ENDDA

WHERE M1~PERNR IN PERNR AND

M1~BEGDA IN BEGDA AND

M1~ENDDA IN ENDDA .

IF SY-SUBRC <> 0 .

MESSAGE 'DATA NOT FOUND' TYPE 'W' .

ENDIF .

LOOP AT ITAB .

SELECT SINGLE KTEXT FROM T556B INTO (ITAB-KTEXT) WHERE KTART = ITAB-KTART.

SELECT SINGLE ATEXT FROM T554T INTO (ITAB-ATEXT) WHERE AWART = ITAB-AWART.

MODIFY ITAB INDEX SY-TABIX TRANSPORTING KTEXT ATEXT.

ENDLOOP.

former_member536879
Active Contributor
0 Kudos

Hi,

Please see the SCN Rules before posting.

With Regards,

Sumodh.P

former_member233090
Active Contributor
0 Kudos

hi,

you want to subtract quoto number and number of days?

ITAB-ANZHL and ITAB-ABWTG ?

quto number no of days?

are you sure?

cheers

bhavana

0 Kudos

Hi,

yes

itab-abwtg is absence days.

0 Kudos

Hi,

LOOP AT ITAB into wa_itab

A = wa_itab- ANZHL- wa_itab-abwtg.

append wa_itab into itab.

ENDLOOP.

cheers,

bhavana