Application Development and Automation 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: 
Read only

Programing code question

Former Member
0 Likes
995

Hi Gurus,

I want to create additional field in the report, where I want to do multiplication with (-1);

how to append a new deffined field ZDMBTR to INT internal table?

Code is displayed below.

Thanks.

data: int like ZFI_GET_COMM_ITE occurs 0 with header line.

SELECT * FROM BSIK WHERE ( BUKRS IN BUKRS ) AND

( LIFNR IN LIFNR ) AND

( BLDAT IN BLDAT ) AND

( BUDAT IN BUDAT ) AND

( CPUDT IN CPUDT ).

SELECT * FROM bseg WHERE ( BELNR = BSIK-BELNR ) AND

( BUKRS = BSIK-BUKRS ) and

( GJAHR = BSIK-GJAHR ) and

( BUZID NE ' ' ).

IF BSIK-SHKZG = 'H'.

ZDMBTR = int-DMBTR * ( -1 ).

ELSE.

ZDMBTR = int-DMBTR.

ENDIF.

IF sy-subrc = 0.

  • CLEAR int.

MOVE-CORRESPONDING bsik TO int.

MOVE-CORRESPONDING bseg TO int.

APPEND int.

ENDIF.

ENDSELECT.

ENDSELECT.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
965
types: BEGIN OF sat.
include structure mara."ZFI_GET_COMM_ITE.
TYPES: zdmbtr TYPE dmbtr,
       end of sat.

DATA: int TYPE TABLE OF sat WITH HEADER LINE.


IF BSIK-SHKZG = 'H'.
INT-ZDMBTR = BSIK-DMBTR * ( -1 ).
ELSE.
INT-ZDMBTR = BSIK-DMBTR.
ENDIF.

Regards

Sathar

8 REPLIES 8
Read only

ThomasZloch
Active Contributor
0 Likes
965

Just add ZDMBTR to DDIC structure ZFI_GET_COMM_ITE. Then you can fill with your calculated value in internal table INT. Also move the MOVE-CORRESPONDING part before the calculation.

Am I missing something?

Thomas

Read only

matt
Active Contributor
0 Likes
965

I thought the same.

Btw - don't use tables with header-lines - it's bad programming practice, which is why SAP banned it in ABAP Objects. Avoid SELECT... ENDSELECT.

Read only

Former Member
0 Likes
965

Hello


DATA: BEGIN OF INT OCCURS 0.
INCLUDE STRUCTURE ZFI_GET_COMM_ITE.
DATA: ZDMBTR LIKE BSEG-DMBTR.
DATA: END OF INT.

Read only

matt
Active Contributor
0 Likes
965

>

> Hello

>

>


> DATA: BEGIN OF INT OCCURS 0.
> INCLUDE STRUCTURE ZFI_GET_COMM_ITE.
> DATA: ZDMBTR LIKE BSEG-DMBTR.
> DATA: END OF INT.
> 

Note: doesn't work in ABAP Objects context.

Read only

0 Likes
965

Hello

Matthew wrote:

Note: doesn't work in ABAP Objects context.

Agree, but in statement of the problem was not nothing be said about ABAP Objects context. (-:

Read only

Former Member
0 Likes
965

Hi ,

Create that field in table ZFI_GET_COMM_ITE OR

Declare your int as

Data : begin on int opccurs 0 with header line .

Include structure ZFI_GET_COMM_ITE .

ZDMBTR TYPE DMBTR.

Data : END OF inT .

Read only

Former Member
0 Likes
965

Hi,

Instead of "data: int like ZFI_GET_COMM_ITE occurs 0 with header line."

use: data: begin of int occurs 0,

include structure ZFI_GET_COMM_ITE ,

<your field> type <type of field>,

end of int.

Read only

Former Member
0 Likes
966
types: BEGIN OF sat.
include structure mara."ZFI_GET_COMM_ITE.
TYPES: zdmbtr TYPE dmbtr,
       end of sat.

DATA: int TYPE TABLE OF sat WITH HEADER LINE.


IF BSIK-SHKZG = 'H'.
INT-ZDMBTR = BSIK-DMBTR * ( -1 ).
ELSE.
INT-ZDMBTR = BSIK-DMBTR.
ENDIF.

Regards

Sathar