2008 Nov 11 1:07 AM
Hi ,
i have created a custom program for purchase order release details ,there are columns like created by , realeased by in the output .But if i create the purchase order and some other person changes the line item and releases it ,the names in the output are being pointed to header only.i want to display the
exact person name in the released by column who have changed the line item and released it.
Thanks&Regards
2008 Nov 11 9:09 AM
Hello!
Below is the sample code to acheive a similar requirement for PRs. You can adapt the logic for POs. Important tables are: t16fs, t16fd and cdpos.
LOOP AT gt_eban_ebkn INTO gs_eban_ebkn.
AT NEW bnfpo.
Change color for every new PR item
IF lv_color EQ gc_x.
CLEAR lv_color.
gs_display-color = 'C210'.
ELSE.
lv_color = gc_x.
CLEAR gs_display-color.
ENDIF.
ENDAT.
Based on the PR release strategy, get the relevant release codes
SELECT SINGLE * FROM t16fs
INTO ls_t16fs
WHERE frggr EQ gs_eban_ebkn-frggr
AND frgsx EQ gs_eban_ebkn-frgst.
MOVE-CORRESPONDING gs_eban_ebkn TO gs_display.
Get vendor name
READ TABLE gt_lfa1 INTO gs_lfa1
WITH KEY lifnr = gs_eban_ebkn-lifnr
BINARY SEARCH.
IF sy-subrc EQ 0.
CONCATENATE gs_lfa1-name1
gs_lfa1-name2
INTO gs_display-vname
SEPARATED BY space.
ENDIF.
lv_offset = 0.
lv_applvl = gc_x.
lv_cnt_loop = 1.
Since only 8 release levels are possible, loop 8 times
DO 8 TIMES.
Get the release code corresponding to the loop counter
CONCATENATE 'LS_T16FS-FRGC'
lv_cnt_loop
INTO lv_fname.
Move release code
ASSIGN (lv_fname) TO <fs_frgc>.
IF <fs_frgc> IS ASSIGNED AND
NOT <fs_frgc> IS INITIAL.
gs_display-frgco = <fs_frgc>.
Select the approver name from T16FD
SELECT SINGLE frgct FROM t16fd
INTO gs_display-name
WHERE spras EQ sy-langu
AND frggr EQ gs_eban_ebkn-frggr
AND frgco EQ <fs_frgc>.
ELSE.
If release code is not defined, exit
EXIT.
ENDIF.
Field FRGZU is populated with 'X' for every release level
When level 1 is approved, FRGZU = X (i.e. FRGZU+0(1) = 'X' )
When level 2 is approved, FRGZU = XX (i.e. FRGZU+1(1) = 'X' )
IF gs_eban_ebkn-frgzu+lv_offset(1) EQ gc_x.
Approved
gs_display-status = 'Approved'(033).
lv_key(3) = sy-mandt. "Client
lv_key+3(10) = gs_eban_ebkn-banfn. "PR Number
lv_key+13(5) = gs_eban_ebkn-bnfpo. "PR Item
lv_objid = gs_eban_ebkn-banfn. "PR Number-Object Id
Get change number for the approval from CDPOS
SELECT changenr FROM cdpos
INTO lv_change
UP TO 1 ROWS
WHERE objectclas EQ 'BANF'
AND objectid EQ lv_objid
AND tabname EQ 'EBAN'
AND fname EQ 'FRGZU'
AND tabkey EQ lv_key
AND value_new EQ lv_applvl.
ENDSELECT.
Get details for the person who made the change from CDHDR
SELECT SINGLE username
udate
utime
FROM cdhdr
INTO ls_cdhdr
WHERE objectclas EQ 'BANF'
AND objectid EQ lv_objid
AND changenr EQ lv_change.
WRITE ls_cdhdr-udate TO gs_display-datum.
WRITE ls_cdhdr-utime TO gs_display-uzeit.
gs_display-uname = ls_cdhdr-username. "Approved by
ELSE.
Pending
gs_display-status = 'Pending'(034).
ENDIF.
Append display table
APPEND gs_display TO gt_display.
Get the value for next approval level
CONCATENATE lv_applvl
gc_x
INTO lv_applvl.
lv_cnt_loop = lv_cnt_loop + 1.
lv_offset = lv_offset + 1.
ENDDO.
ENDLOOP.
Cheers!
Hi ,
i have created a custom program for purchase order release details ,there are columns like created by , realeased by in the output .But if i create the purchase order and some other person changes the line item and releases it ,the names in the output are being pointed to header only.i want to display the
exact person name in the released by column who have changed the line item and released it.
Thanks&Regards
2008 Nov 11 9:09 AM
Hello!
Below is the sample code to acheive a similar requirement for PRs. You can adapt the logic for POs. Important tables are: t16fs, t16fd and cdpos.
LOOP AT gt_eban_ebkn INTO gs_eban_ebkn.
AT NEW bnfpo.
Change color for every new PR item
IF lv_color EQ gc_x.
CLEAR lv_color.
gs_display-color = 'C210'.
ELSE.
lv_color = gc_x.
CLEAR gs_display-color.
ENDIF.
ENDAT.
Based on the PR release strategy, get the relevant release codes
SELECT SINGLE * FROM t16fs
INTO ls_t16fs
WHERE frggr EQ gs_eban_ebkn-frggr
AND frgsx EQ gs_eban_ebkn-frgst.
MOVE-CORRESPONDING gs_eban_ebkn TO gs_display.
Get vendor name
READ TABLE gt_lfa1 INTO gs_lfa1
WITH KEY lifnr = gs_eban_ebkn-lifnr
BINARY SEARCH.
IF sy-subrc EQ 0.
CONCATENATE gs_lfa1-name1
gs_lfa1-name2
INTO gs_display-vname
SEPARATED BY space.
ENDIF.
lv_offset = 0.
lv_applvl = gc_x.
lv_cnt_loop = 1.
Since only 8 release levels are possible, loop 8 times
DO 8 TIMES.
Get the release code corresponding to the loop counter
CONCATENATE 'LS_T16FS-FRGC'
lv_cnt_loop
INTO lv_fname.
Move release code
ASSIGN (lv_fname) TO <fs_frgc>.
IF <fs_frgc> IS ASSIGNED AND
NOT <fs_frgc> IS INITIAL.
gs_display-frgco = <fs_frgc>.
Select the approver name from T16FD
SELECT SINGLE frgct FROM t16fd
INTO gs_display-name
WHERE spras EQ sy-langu
AND frggr EQ gs_eban_ebkn-frggr
AND frgco EQ <fs_frgc>.
ELSE.
If release code is not defined, exit
EXIT.
ENDIF.
Field FRGZU is populated with 'X' for every release level
When level 1 is approved, FRGZU = X (i.e. FRGZU+0(1) = 'X' )
When level 2 is approved, FRGZU = XX (i.e. FRGZU+1(1) = 'X' )
IF gs_eban_ebkn-frgzu+lv_offset(1) EQ gc_x.
Approved
gs_display-status = 'Approved'(033).
lv_key(3) = sy-mandt. "Client
lv_key+3(10) = gs_eban_ebkn-banfn. "PR Number
lv_key+13(5) = gs_eban_ebkn-bnfpo. "PR Item
lv_objid = gs_eban_ebkn-banfn. "PR Number-Object Id
Get change number for the approval from CDPOS
SELECT changenr FROM cdpos
INTO lv_change
UP TO 1 ROWS
WHERE objectclas EQ 'BANF'
AND objectid EQ lv_objid
AND tabname EQ 'EBAN'
AND fname EQ 'FRGZU'
AND tabkey EQ lv_key
AND value_new EQ lv_applvl.
ENDSELECT.
Get details for the person who made the change from CDHDR
SELECT SINGLE username
udate
utime
FROM cdhdr
INTO ls_cdhdr
WHERE objectclas EQ 'BANF'
AND objectid EQ lv_objid
AND changenr EQ lv_change.
WRITE ls_cdhdr-udate TO gs_display-datum.
WRITE ls_cdhdr-utime TO gs_display-uzeit.
gs_display-uname = ls_cdhdr-username. "Approved by
ELSE.
Pending
gs_display-status = 'Pending'(034).
ENDIF.
Append display table
APPEND gs_display TO gt_display.
Get the value for next approval level
CONCATENATE lv_applvl
gc_x
INTO lv_applvl.
lv_cnt_loop = lv_cnt_loop + 1.
lv_offset = lv_offset + 1.
ENDDO.
ENDLOOP.
Cheers!