Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9236

ABAP (SAP) Join 3 tables together and display the searched number using ALV

$
0
0

I am having difficulty joining the 3 tables together and then displaying them using ALV. The employee number shows in the ALV and so does the location, but the name of the person does not. I know their is an error in the SELECT statements but cant seem to figure it out. Any help would be appreciated.


TYPE-POOLS: slis.

TABLES: PA0000, PA0001, PA0002.

TYPES: BEGIN OF PA0000,
  pernr TYPE pa0000-pernr,
  stat2 TYPE pa0000-stat2,
END OF pa0000.

TYPES: BEGIN OF PA0001,
  pernr TYPE pa0001-pernr,
  werks TYPE pa0001-werks,
END OF pa0001.

TYPES: BEGIN OF PA0002,
  pernr TYPE pa0002-pernr,
  vorna TYPE pa0002-vorna,
  nachn TYPE pa0002-nachn,
END OF pa0002.

DATA: gwa_employee TYPE TABLE OF pa0000.
DATA: gwa_employee1 TYPE TABLE OF pa0001.
DATA: gwa_employee2 TYPE TABLE OF pa0002.
DATA: gw_table TYPE STANDARD TABLE OF pa0001.


DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
  wa_fieldcat TYPE slis_fieldcat_alv.

PARAMETERS input TYPE pa0000-PERNR.


START-OF-SELECTION.

*Fetch data from the database
SELECT pernr stat2
  FROM pa0000
  INTO TABLE gwa_employee
* FOR ALL ENTRIES IN gw_table
  WHERE pernr = input AND stat2 = '3'.

  SELECT pernr werks
  FROM pa0001
  INTO TABLE gw_table
* FOR ALL ENTRIES IN gwa_employee
  WHERE pernr = input.
*AND werks = 'AUH'

  SELECT pernr vorna nachn
  FROM pa0002
  INTO TABLE gwa_employee2
* FOR ALL ENTRIES IN gwa_employee1
  WHERE pernr = input.


*Build field catalog

wa_fieldcat-fieldname = 'PERNR'.
wa_fieldcat-seltext_m = 'Employee Number'.
APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'WERKS'.
wa_fieldcat-seltext_m = 'Location'.
APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'VORNA'.
wa_fieldcat-seltext_m = 'First Name'.
APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-fieldname = 'NACHN'.
wa_fieldcat-seltext_m = 'Last Name'.
APPEND wa_fieldcat TO it_fieldcat.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
  it_fieldcat = it_fieldcat
  TABLES
  t_outtab = gw_table
  EXCEPTIONS
  program_error = 1
  OTHERS = 2.


Viewing all articles
Browse latest Browse all 9236

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>