cancel
Showing results for 
Search instead for 
Did you mean: 

Field groups

Former Member
0 Kudos

data: begin of %g00 occurs 100,

AFPO-AUFNR like AFPO-AUFNR,

Aging type p,

end of %g00.

field-groups header.

field-groups %fg01.

data : time type SYUZEIT.

data : Aging type p.

insert AFPO-AUFNR into %fg01.

insert Aging into %fg01.

select AFPOAUFNR AFKOFTRMS

into (AFPO-AUFNR , AFKO-FTRMS ) from ( AFPO

inner join AFKO

on AFKOAUFNR = AFPOAUFNR ).

select single * from AFKO where AUFNR = AFPO-AUFNR.

if sy-subrc = 0.

CALL FUNCTION '/SDF/CMO_DATETIME_DIFFERENCE'

EXPORTING

DATE1 = AFKO-FTRMS

TIME1 = time

DATE2 = sy-datum

TIME2 = time

IMPORTING

DATEDIFF = aging

EXCEPTIONS

INVALID_DATETIME = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

ENDIF.

endif.

extract %fg01.

endselect.

In this code i have added aging filed, but it's not fetching the Aging data....Please help me.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

Refer this sample code:

tables: mara.

types : begin of str_mara,

matnr type matnr,
mtart type mtart,
meins type meins,
matkl type matkl,
ernam type ernam,
mbrsh type mbrsh,
bstme type bstme,

end of str_mara.

data: wa_mara type str_mara,
it_mara type standard table of str_mara.

field-groups: fld_grp.

start-of-selection.

insert mara-matnr mara-mtart mara-meins
mara-matkl mara-ernam mara-mbrsh mara-bstme into fld_grp.

select matnr mtart meins matkl ernam mbrsh bstme from mara into
correspoNDING FIELDS OF mara.

extract fld_grp.

endselect.

*SORT ASCENDING .
clear mara.

loop.

at fld_grp .
wa_mara-matnr = mara-matnr.
wa_mara-mtart = mara-mtart.
wa_mara-meins = mara-meins.
wa_mara-matkl = mara-matkl.
wa_mara-ernam = mara-ernam.
wa_mara-mbrsh = mara-mbrsh.
wa_mara-bstme = mara-bstme.

append wa_mara to it_mara.
endat.

endloop.

loop at it_mara into wa_mara.

write:/ wa_mara-matnr, wa_mara-mtart, wa_mara-meins.

endloop.

Regards,

Sravanthi

Former Member
0 Kudos

In the above code, can i add new variable (not table field) into field group?

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi subramanyam

Check this code the data is getting displayed

TABLES:
  afpo,
  afko.

DATA:
BEGIN OF %g00 OCCURS 100,
aufnr type afpo-aufnr,
END OF %g00.

DATA:
 aging TYPE p,
 time TYPE sy-uzeit.


FIELD-GROUPS :
fg_afpo.                               " Field group afpo

insert AFPO-AUFNR Aging into fg_afpo.

select AFPO~AUFNR
       AFKO~FTRMS
into (AFPO-AUFNR , AFKO-FTRMS )
from ( AFPO inner join AFKO
on AFKO~AUFNR = AFPO~AUFNR ).

select single *
from AFKO
where AUFNR = AFPO-AUFNR.

if sy-subrc = 0.
CALL FUNCTION '/SDF/CMO_DATETIME_DIFFERENCE'
EXPORTING
DATE1 = AFKO-FTRMS
TIME1 = time
DATE2 = sy-datum
TIME2 = time
IMPORTING
DATEDIFF = aging
EXCEPTIONS
INVALID_DATETIME = 1
OTHERS = 2.
IF SY-SUBRC eq 0.
ENDIF.
endif.

extract fg_afpo.
write:
 / afpo-aufnr,
   afko-ftrms.

endselect.

Regards,

Sravanthi

Former Member
0 Kudos

Sravanthi,

Your correct but,

in my report i need to display data in the two ways

one is abap list other on is ALV report. i have used your logic it is showing new field in abap list but not in ALV list....please i need to get new field in ALV list.

Former Member
0 Kudos

Please any idea about this issue.

Former Member
0 Kudos

Any body there to give solution

Former Member
0 Kudos

I got solution. We have to maintain structure fields as a referrence in declaration of any variables which are using to pass ALV report. Means in my case i have to show new field in ALV report and had to do calculation on that field. So i can't declare Aging(10) type p.

we have to create new structure with aging field and have to take reference like below..

Aging type ZAGING-AGING.

ZAGING is the dictionary structure...

Thanks

Former Member
0 Kudos

Hi subramanyam,

Your way of declaration is also correct.

Just check with your Function Module..Whether it is returning correct value or not.

And just go to se38 (ABAP Editor : Initial Screen)

Environment -> Examples -> ABAP Examples

Go to The ABAP Programming Language -> Processing Large Dataset -> Extracts.

Here you will get some good examples on field groups.

Just double click on Extracts, This will take you to a very nice documentation of Field groups.

Hope this will help.

Regards,

Nitin,

Former Member
0 Kudos

Function Module getting correct value..I have checked in ABAP Examples also, i am following the same way..

Former Member
0 Kudos

Hi

Dont use two different insert statement just use one insert statement

insert AFPO-AUFNR  Aging  into %fg01.

In your code you have declared aging twice one in the structure and other after time sy-uzeit.

Regards,

Sravanthi

Former Member
0 Kudos

I dont think problem with Insert statment....

Is there any defference between both way of

1)insert AFPO-AUFNR Aging into %fg01.

&

2)insert AFPO-AUFNR into %fg01.

insert Aging into %fg01.

Former Member
0 Kudos

Hi

You can add field in the field-groups using insert

Insert AFPO-AUFNR Aging into %fg01.

Regards,

Sravanthi

Former Member
0 Kudos

Yes, i have added new variable field, like below

Insert AFPO-AUFNR into %fg01.

Insert Aging into %fg01.

Is it correct way or not?

Former Member
0 Kudos

Hi Subramanyam,

In case of field groups, You can not add any field after execution of EXTRACT statement.

If you want to add any field, you'll have to add it in INSERT....INTO statement only before EXTRACT statement.

Regards,

Nitin.

Former Member
0 Kudos

Yes, I have added new variable "Aging" before exceute EXTRACT statment.

Please reffer my code, but i am getting the variable data in output.

Former Member
0 Kudos

Hi Subramanyam,

Just go through the following link, this will give you enough information about field group.

Hopr this will help.

Regards,

Nitin.

Former Member
0 Kudos

Please any body give solution.