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: 

picking data

Former Member
0 Kudos

Hi gurus,

My alv grid has a field Department(KOSTL), i am displaying it thru the final internal table it_final. the problem this department is being peicked from two tables ie ESKN and COBRB depending on the condition KNTTP = F or K.

i am able to display fields from table in the grid, suppose for condition KNTTP = F.

how to input the data in the same field if KNTTP = K.

IF NOT it_eskn[] IS INITIAL.

count = 1.

LOOP AT it_eskn.

it_final-kostl = it_eskn-kostl.

MODIFY it_final INDEX count TRANSPORTING kostl.

count = count + 1.

CLEAR it_final.

ENDLOOP.

ENDIF.

now i am able to move it_eskn-kostl to final internal table. but i also want to move it_cobrb-kostl to the same field of the final internal table ie it_final-kostl.

please help me guys

Thanks in advance

regards,

alson

4 REPLIES 4

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

I am not sure whether I understadn the situation correctly.

IF NOT it_eskn[] IS INITIAL.

count = 1.

LOOP AT it_eskn.

it_final-kostl = it_eskn-kostl.

MODIFY it_final INDEX count TRANSPORTING kostl.

count = count + 1.

CLEAR it_final.

ENDLOOP.

IF NOT it_cobrb[] IS INITIAL.

count = 1.

LOOP AT it_cobrb.

it_final-kostl = it_cobrb-kostl.

MODIFY it_final INDEX count TRANSPORTING kostl.

count = count + 1.

CLEAR it_final.

ENDLOOP.

ENDIF.

Former Member
0 Kudos

IF NOT it_eskn[] IS INITIAL.

count = 1.

LOOP AT it_eskn.

<b>if KNTTP eq 'F'

it_final-kostl = it_eskn-kostl.

elseif KNTTP eq 'K'.

it_final-kostl = it_cocrb-kostl.

endif.</b>

MODIFY it_final INDEX count TRANSPORTING kostl.

count = count + 1.

CLEAR it_final.

ENDLOOP.

ENDIF.

Former Member
0 Kudos

You can change ur code like below

data: g_tabix like sy-tabix.

IF NOT it_final[] IS INITIAL.

LOOP AT it_final.

g_tabix = sy-tabix.

if it_final-knttp = 'F'.

read table it_eskn with key "Here you check the key field in final &eskn table

if sy-subrc = 0.

it_final-kostl = it_eskn-kostl.

MODIFY it_final INDEX g_tabix TRANSPORTING kostl.

endif.

elseif it_final-knttp = 'K'.

read table it_cobrb with key

if sy-subrc = 0.

it_final-kostl = it_cobrb-kostl.

MODIFY it_final INDEX g_tabix TRANSPORTING kostl.

endif.

endif.

CLEAR it_final.

ENDLOOP.

ENDIF.

IF NOT it_eskn[] IS INITIAL.

count = 1.

LOOP AT it_eskn.

it_final-kostl = it_eskn-kostl.

MODIFY it_final INDEX count TRANSPORTING kostl.

count = count + 1.

CLEAR it_final.

ENDLOOP.

ENDIF.

Former Member
0 Kudos

hi shaik,

first of all thanks for ur interest. the problem is i am not picking any data in the final internal table. i am just moving the the data from all the internal tables to final internal table. the code is below. plese go thru it and suggest me the sol.

*********************TABLES DECLARATION******************************

TABLES: prps,esll,eskn,essr,essr_rel,csks,lfa1,aufk,cobrb,proj,t001w,

ymmessr,

ymmlfa1.

*****************TYPE GROUP DECLARATION******************************

TYPE-POOLS : slis.

****************SELECTION SCREEN DECLARATION*************************

SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS: s_werks FOR t001w-werks OBLIGATORY NO INTERVALS,

s_date FOR essr-budat OBLIGATORY.

SELECTION-SCREEN: END OF BLOCK b1.

SELECTION-SCREEN: BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS: p_rad1 RADIOBUTTON GROUP rept.

SELECTION-SCREEN COMMENT 3(10) text-003.

PARAMETERS: p_rad2 RADIOBUTTON GROUP rept.

SELECTION-SCREEN COMMENT 16(10) text-004.

PARAMETERS: p_rad3 RADIOBUTTON GROUP rept.

SELECTION-SCREEN COMMENT 30(10) text-005.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN: END OF BLOCK b2.

************************VARIABLE DECLARATIONS***********************

DATA: g_repid LIKE sy-repid.

*********************FIELD CATALOG DECLARATION***********************

DATA: ls_fieldcat TYPE slis_fieldcat_alv.

DATA: layout_wa TYPE slis_layout_alv.

DATA: p_it_st_fieldcat TYPE slis_fieldcat_alv OCCURS 0.

DATA: ls_sort TYPE slis_sortinfo_alv,

it_sort TYPE slis_t_sortinfo_alv.

********************ALV HEADING**************************************

DATA: v_plant(40),

v_date(40),

v_capex(10),

v_rd(10),

v_rm(10),

v_packno LIKE eslh-ebeln,

p_packno LIKE eslh-ebeln,

count LIKE sy-tabix.

DATA: shed TYPE slis_listheader. "For Feild Cat.

DATA: ithed TYPE slis_t_listheader. "For Feild Cat.

********************INTERNAL TABLE DECLARATION************************

DATA:BEGIN OF it_esll OCCURS 0,

srvpos LIKE esll-srvpos,

introw LIKE esll-introw,

netwr LIKE esll-netwr,

menge LIKE esll-menge,

packno LIKE esll-packno,

END OF it_esll.

DATA:BEGIN OF it_essr OCCURS 0,

lblni LIKE essr-lblni,

packno LIKE essr-packno,

kzabn LIKE essr-kzabn,

knttp LIKE essr-knttp,

introw LIKE it_esll-introw,

END OF it_essr.

DATA:BEGIN OF it_essr_rel OCCURS 0,

lifnr LIKE essr_rel-lifnr,

lblni LIKE essr_rel-lblni,

packno LIKE essr_rel-packno,

kzabn LIKE essr_rel-kzabn,

knttp LIKE essr_rel-knttp,

END OF it_essr_rel.

DATA:BEGIN OF it_eskn OCCURS 0,

ps_psp_pnr LIKE eskn-ps_psp_pnr,

kostl LIKE eskn-kostl,

aufnr LIKE eskn-aufnr,

knttp LIKE essr-knttp,

END OF it_eskn.

DATA:BEGIN OF it_ymmlfa1 OCCURS 0,

lifnr LIKE lfa1-lifnr,

END OF it_ymmlfa1.

DATA:BEGIN OF it_csks OCCURS 0,

khinr LIKE csks-khinr,

kostl LIKE csks-kostl,

END OF it_csks.

DATA:BEGIN OF it_cskt OCCURS 0,

ltext LIKE cskt-ltext,

kostl LIKE cskt-kostl,

END OF it_cskt.

DATA:BEGIN OF it_prps OCCURS 0,

pspnr LIKE prps-pspnr,

vernr LIKE prps-vernr,

END OF it_prps.

DATA:BEGIN OF it_ymmessr OCCURS 0,

srvpos LIKE esll-srvpos,

END OF it_ymmessr.

DATA:BEGIN OF it_aufk OCCURS 0,

objnr LIKE aufk-objnr,

aufnr LIKE aufk-aufnr,

END OF it_aufk.

DATA:BEGIN OF it_cobrb OCCURS 0,

kostl LIKE cobrb-kostl,

END OF it_cobrb.

DATA:BEGIN OF it_proj OCCURS 0,

profl LIKE proj-profl,

END OF it_proj.

DATA:BEGIN OF it_final OCCURS 0,

kzabn LIKE it_essr-kzabn,

knttp LIKE it_essr-knttp,

kostl LIKE it_eskn-kostl,

aufnr LIKE it_eskn-aufnr,

khinr LIKE it_csks-khinr,

vernr LIKE it_prps-vernr,

objnr LIKE it_aufk-objnr,

aufnr1 LIKE it_aufk-aufnr,

srvpos LIKE it_ymmessr-srvpos,

ltext LIKE it_cskt-ltext,

lifnr LIKE it_ymmlfa1-lifnr,

menge LIKE it_esll-menge,

netwr LIKE it_esll-netwr,

lblni LIKE essr_rel-lblni,

packno LIKE essr_rel-packno,

profl LIKE proj-profl,

v_srvpos(20) TYPE n,

END OF it_final.

************************INITIALIZATION*************************

INITIALIZATION.

g_repid = sy-repid .

************************START OF SELECTION************************

START-OF-SELECTION.

************************SELECTING DATA****************************

IF p_rad3 = 'X'.

PERFORM select_data.

PERFORM fieldcatalog.

PERFORM sort.

PERFORM layout.

PERFORM display.

ENDIF.

IF p_rad1 = 'X'.

PERFORM select_data1.

PERFORM fieldcatalog1.

PERFORM sort1.

PERFORM display1.

ELSEIF p_rad2 = 'X'.

PERFORM select_data1.

PERFORM fieldcatalog1.

PERFORM sort1.

PERFORM display1.

ENDIF.

&----


*& Form SELECT_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM select_data.

SELECT netwr srvpos menge packno introw

FROM esll

INTO CORRESPONDING FIELDS OF TABLE it_esll.

IF sy-subrc = 0.

SELECT * FROM ymmessr

INTO CORRESPONDING FIELDS OF TABLE it_ymmessr

FOR ALL ENTRIES IN it_esll

WHERE srvpos = it_esll-srvpos.

ENDIF.

IF NOT it_esll[] IS INITIAL.

SELECT lblni packno knttp

FROM essr

INTO CORRESPONDING FIELDS OF TABLE it_essr

WHERE kzabn = 'X'

AND ( knttp = 'K' ) OR ( knttp = 'F' )

AND packno = it_esll-packno.

ENDIF.

IF NOT it_essr[] IS INITIAL.

LOOP AT it_essr.

CALL FUNCTION 'MS_GET_EXTERNAL_ROW'

EXPORTING

i_packno = it_essr-packno

i_introw = '0000000000'

IMPORTING

e_ebeln = v_packno.

MOVE v_packno TO it_essr-packno.

MODIFY it_essr INDEX sy-tabix TRANSPORTING packno.

ENDLOOP.

ENDIF.

SELECT kostl aufnr

FROM eskn

INTO CORRESPONDING FIELDS OF TABLE it_eskn

FOR ALL ENTRIES IN it_essr

WHERE packno = it_essr-packno.

IF sy-subrc = 0..

SELECT khinr

FROM csks

INTO CORRESPONDING FIELDS OF TABLE it_csks

FOR ALL ENTRIES IN it_eskn

WHERE kostl = it_eskn-kostl.

ENDIF.

IF NOT it_csks[] IS INITIAL.

SELECT ltext

FROM cskt

INTO CORRESPONDING FIELDS OF TABLE it_cskt

FOR ALL ENTRIES IN it_eskn

WHERE kostl = it_eskn-kostl.

ENDIF.

IF NOT it_eskn[] IS INITIAL.

SELECT objnr

FROM aufk

INTO CORRESPONDING FIELDS OF TABLE it_aufk

FOR ALL ENTRIES IN it_eskn

WHERE aufnr = it_eskn-aufnr.

ENDIF.

IF NOT it_aufk[] IS INITIAL.

SELECT kostl

FROM cobrb

INTO CORRESPONDING FIELDS OF TABLE it_cobrb

FOR ALL ENTRIES IN it_aufk

WHERE objnr = it_aufk-objnr.

ENDIF.

IF NOT it_ymmessr[] IS INITIAL.

  • SORT it_ymmessr.

count = 1.

LOOP AT it_ymmessr.

it_final-srvpos = it_ymmessr-srvpos.

APPEND it_final.

count = count + 1.

CLEAR it_final.

ENDLOOP.

ENDIF.

IF NOT it_csks[] IS INITIAL.

count = 1.

LOOP AT it_csks.

it_final-khinr = it_csks-khinr.

MODIFY it_final INDEX count TRANSPORTING khinr.

count = count + 1.

CLEAR it_final.

ENDLOOP.

ENDIF.

IF NOT it_eskn[] IS INITIAL.

count = 1.

LOOP AT it_eskn.

it_final-kostl = it_eskn-kostl.

MODIFY it_final INDEX count TRANSPORTING kostl.

count = count + 1.

CLEAR it_final.

ENDLOOP.

ENDIF.

IF NOT it_cskt[] IS INITIAL.

count = 1.

LOOP AT it_cskt.

it_final-ltext = it_cskt-ltext.

MODIFY it_final INDEX count TRANSPORTING ltext.

count = count + 1.

CLEAR it_final.

ENDLOOP.

ENDIF.

IF NOT it_esll[] IS INITIAL.

count = 1.

LOOP AT it_esll.

it_final-menge = it_esll-menge.

it_final-netwr = it_esll-netwr.

MODIFY it_final INDEX count TRANSPORTING menge netwr.

count = count + 1.

CLEAR it_final.

ENDLOOP.

ENDIF.

ENDFORM. " SELECT_DATA

Thanks in advance.

Regards

alson