Skip to Content
0
Former Member
Oct 28, 2013 at 09:32 AM

Need some help in SAPScript

64 Views

Hi guys, I'm just a beginner in abap. I got some problem with SAPscript(receipt of payment for HR). The output didn't show the data that I need (I label it with red line). Can you give me some suggestions to repair this?

TABLES: pa0001, pa0002, pa0015, pa0021, pa0185, pa0267.

TYPES: BEGIN OF t_pa0001,
pernr LIKE PA0001-pernr,
END OF t_pa0001.

TYPES: BEGIN OF t_pa0002,
begda LIKE PA0002-begda, "Begin date
endda LIKE PA0002-endda, "End Date
cname LIKE PA0002-cname, "Employee Name
END OF t_pa0002.

TYPES: BEGIN OF t_pa0015,
betrg LIKE PA0015-betrg, "total amount
begda LIKE PA0015-begda, "payment date
END OF t_pa0015.

TYPES: BEGIN OF t_pa0021,
fcnam LIKE P0021-fcnam, "Assured name
END OF t_pa0021.

TYPES: BEGIN OF t_pa0185,
icnum LIKE PA0185-icnum, "ic number
subty LIKE PA0185-subty,
END OF t_pa0185.

TYPES: BEGIN OF t_pa0267,
lgart LIKE PA0267-lgart, "wage type
END OF t_pa0267.

TYPES: BEGIN OF t_data,
betrg LIKE PA0015-betrg,
begda LIKE PA0015-begda,
fcnam LIKE PA0021-fcnam,
pernr LIKE PA0001-pernr,
cname LIKE PA0002-cname,
subty LIKE PA0185-subty,
icnum LIKE PA0185-icnum,
lgart LIKE PA0267-lgart,
endda LIKE pa0002-endda,

END OF t_data.

DATA: it_pa0001 TYPE TABLE OF t_pa0001,
wa_pa0001 TYPE t_pa0001,
it_pa0002 TYPE TABLE OF t_pa0002,
wa_pa0002 TYPE t_pa0002,
it_pa0015 TYPE TABLE OF t_pa0015,
wa_pa0015 TYPE t_pa0015,
it_pa0021 TYPE TABLE OF t_pa0021,
wa_pa0021 TYPE t_pa0021,
it_pa0185 TYPE TABLE OF t_pa0185,
wa_pa0185 TYPE t_pa0185,
it_pa0267 TYPE TABLE OF t_pa0267,
wa_pa0267 TYPE t_pa0267,
it_data TYPE TABLE OF t_data,
wa_data TYPE t_data.

SELECT-OPTIONS:
s_begda FOR PA0002-begda,
s_endda FOR PA0002-endda,
s_pernr FOR PA0001-pernr,
s_lgart FOR PA0267-lgart.

PARAMETERS:
p_cname TYPE PA0002-cname NO-DISPLAY,
p_betrg TYPE PA0015-betrg NO-DISPLAY,
p_fcnam TYPE pa0021-fcnam NO-DISPLAY,
p_icnum TYPE pa0185-icnum NO-DISPLAY,
p_subty TYPE pa0185-subty NO-DISPLAY,
p_begda TYPE pa0015-begda NO-DISPLAY.

START-OF-SELECTION.

PERFORM get_data.
PERFORM open_form.
PERFORM start_form.
PERFORM write_form.
PERFORM end_form.
PERFORM close_form.

*&---------------------------------------------------------------------*
*& For GET_DATA
*&---------------------------------------------------------------------*
* tex Getting data into final internal table for display
*----------------------------------------------------------------------*

FORM get_data.

SELECT pa0001~pernr pa0002~cname
FROM pa0001
INNER JOIN pa0002
ON pa0001~pernr = pa0002~pernr
INTO CORRESPONDING FIELDS OF TABLE it_pa0001
WHERE pa0001~pernr = s_pernr.

LOOP AT it_pa0001 INTO wa_pa0001.
READ TABLE it_pa0001 INTO wa_pa0001 WITH KEY pernr = s_pernr.
IF sy-subrc = 0.
MOVE-CORRESPONDING wa_pa0001 TO wa_data.
ENDIF.
APPEND wa_data to it_data.
ENDLOOP.


SELECT pa0002~cname pa0002~begda pa0002~endda pa0001~pernr
FROM pa0002
INNER JOIN pa0001
ON pa0002~pernr = pa0001~pernr
INTO CORRESPONDING FIELDS OF TABLE it_pa0002
WHERE pa0002~cname = p_cname
AND pa0002~endda IN s_endda
AND pa0002~begda IN s_begda.

LOOP AT it_pa0002 INTO wa_pa0002.
READ TABLE it_pa0002 INTO wa_pa0002 WITH KEY cname = p_cname.
READ TABLE it_pa0002 INTO wa_pa0002 WITH KEY begda = s_begda.
READ TABLE it_pa0002 INTO wa_pa0002 WITH KEY endda = s_endda.
IF sy-subrc = 0.
MOVE-CORRESPONDING wa_pa0002 TO wa_data.
ENDIF.
APPEND wa_data to it_data.
ENDLOOP.


SELECT lgart
FROM pa0267 INTO CORRESPONDING FIELDS OF TABLE it_pa0267
WHERE lgart IN s_lgart.


SELECT pa0015~betrg pa0015~begda pa0001~subty
FROM pa0015
INNER JOIN pa0001
ON pa0001~subty = pa0015~subty
INTO CORRESPONDING FIELDS OF TABLE it_pa0015
WHERE pa0015~betrg = p_betrg
AND pa0015~begda = p_begda.

LOOP AT it_pa0015 INTO wa_pa0015.
READ TABLE it_pa0015 INTO wa_pa0015 WITH KEY betrg = p_betrg.
READ TABLE it_pa0015 INTO wa_pa0015 WITH KEY begda = p_begda.
IF sy-subrc = 0.
MOVE-CORRESPONDING wa_pa0015 TO wa_data.
ENDIF.
APPEND wa_data to it_data.
ENDLOOP.


SELECT pa0021~fcnam pa0001~pernr
FROM pa0021
INNER JOIN pa0001
ON pa0001~pernr = pa0021~pernr
INTO CORRESPONDING FIELDS OF TABLE it_pa0021
WHERE pa0021~fcnam = p_fcnam.

LOOP AT it_pa0021 INTO wa_pa0021.
READ TABLE it_pa0021 INTO wa_pa0021 WITH KEY fcnam = p_fcnam.
IF sy-subrc = 0.
MOVE-CORRESPONDING wa_pa0021 TO wa_data.
ENDIF.
APPEND wa_data TO it_data.
ENDLOOP.

SELECT pa0185~subty pa0185~icnum pa0001~pernr
FROM pa0185
INNER JOIN pa0001
ON pa0001~pernr = pa0185~pernr
INTO CORRESPONDING FIELDS OF TABLE it_pa0185
WHERE pa0185~subty = p_subty
AND pa0185~icnum = p_icnum.

LOOP AT it_pa0185 INTO wa_pa0185.
READ TABLE it_pa0185 INTO wa_pa0185 WITH KEY icnum = p_icnum.
READ TABLE it_pa0185 INTO wa_pa0185 WITH KEY subty = p_subty.
IF sy-subrc = 0.
MOVE-CORRESPONDING wa_pa0185 TO wa_data.
ENDIF.
APPEND wa_data TO it_data.
ENDLOOP.

CLEAR it_data.

ENDFORM. "get_data

*&---------------------------------------------------------------------*
*& Form OPEN_FORM
*&---------------------------------------------------------------------*
* text: opening script form
*----------------------------------------------------------------------*
FORM open_form.

CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM = 'ZHR_DEMO2'
.

ENDFORM. "open_form

*&---------------------------------------------------------------------*
*& Form START_FORM
*&---------------------------------------------------------------------*
* Text: Starting form
*----------------------------------------------------------------------*
FORM start_form.

CALL FUNCTION 'START_FORM'
EXPORTING
FORM = 'ZHR_DEMO2'
.
ENDFORM. "start_form

*&---------------------------------------------------------------------*
*& Form WRITE_FORM
*&---------------------------------------------------------------------*
* text: Writing into form
*----------------------------------------------------------------------*
FORM write_form.

CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW = 'MAIN'
ELEMENT = 'ADDRESS'
.

CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW = 'WINDOW1'
ELEMENT = 'DATE'
.

CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW = 'WINDOW2'
ELEMENT = 'POLICY'
.

CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW = 'WINDOW3'
ELEMENT = 'A_NAME'
.

CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW = 'WINDOW4'
ELEMENT = 'PAYMENT'
.

CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW = 'WINDOW5'
ELEMENT = 'TITLE'
.

CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW = 'WINDOW6'
ELEMENT = 'PERIOD'
.

CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW = 'WINDOW7'
ELEMENT = 'NOTE1'
.

CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW = 'WINDOW8'
ELEMENT = 'NOTE2'
.

CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW = 'WINDOW9'
ELEMENT = 'NOTE3'
.

CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW = 'WINDOW10'
ELEMENT = 'NOTE4'
.

CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW = 'WINDOW11'
ELEMENT = 'NOTE5'
.

ENDFORM. "write_form

*&---------------------------------------------------------------------*
*& Form END_FORM
*&---------------------------------------------------------------------*
* text: Ending form
*----------------------------------------------------------------------*
FORM end_form.

CALL FUNCTION 'END_FORM'
.
IF SY-SUBRC <> 0.
ENDIF.

ENDFORM. "end_form

*&---------------------------------------------------------------------*
*& Form close_form
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM close_form.
CALL FUNCTION 'CLOSE_FORM'
.
ENDFORM. "close_form

Attachments

Sapscript-pic.jpg (52.3 kB)