Application Development and Automation 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: 
Read only

LDB sample program (Hr abap)

Former Member
0 Likes
3,275

Hi,

iam learning HR Abap i want to write a program in ldb's..for example i want to fetch the following

data P0001-WERKS,P0105-USRID,P0002-CNAME,P0000-STAT2,PA0001-PERNR into one internal table

in ldb PNP.how to write the code.please send me the sample coding..

Thx..

10 REPLIES 10
Read only

Former Member
0 Likes
1,885

Swetha,

Welcome to SCN!!!!!!!

Search SCN forum you will find the similar threads...

Read only

Former Member
0 Likes
1,885

Hi

Refer to these 2 programs:

DEMO_SELECTION_SCREEN_LDB_1 and DEMO_SELECTION_SCREEN_LDB_2.

Regards

Raj

Read only

Former Member
0 Likes
1,885

Hi,

declare PNP in the attributes of the program.

report .....

tables : pernr.

infotypes : 0105,0002,0000,0001.

*declare your internal table with all the fields you require.

start-of-selection.

get pernr.

rp-provide-from-last p0001 space pn-begda pn-endda.

if pnp-sw-found = 1.

  • <internal table>-field1 = P0001-PERNR.

similarly fill other fields from PA0001.

endif.

rp-provide-from-last p0105 space pn-begda pn-endda.

if pnp-sw-found = 1.

  • <internal table>-field3 = P0105-USRID.

endif.

rp-provide-from-last p0002 space pn-begda pn-endda.

if pnp-sw-found = 1.

*fill P0002-CNAME,P0000-STAT2 to respective fields of internal table

endif.

end-of-selection.

loop at <internal table> into wa.

*write fields ....

endloop.

Regards,

Srini.

Read only

0 Likes
1,885

Thx Srini let me check it out..

Read only

0 Likes
1,885

Hi srini,

i hav done the coding as u told.but my data is not coming into internal table the data is showing for the field werks and pernr..

please help me out..

Thx.

Read only

0 Likes
1,885

Hi,

write append statement ...

start-of-selection.

get pernr.

rp-provide-from-last p0001 space pn-begda pn-endda.

if pnp-sw-found = 1.

  • it_str-pernr = p0001-pernr.

it_str-werks = p0001-werks.

endif.

rp-provide-from-last p0105 space pn-begda pn-endda.

if pnp-sw-found = 1.

  • it_str-pernr = p0105-usrid.

it_str-usrid = P0105-USRID.

endif.

rp-provide-from-last p0002 space pn-begda pn-endda.

if pnp-sw-found = 1.

*it_str-pernr = p0002-pernr.

it_str-cname = p0002-cname.

endif.

rp-provide-from-last p0000 space pn-begda pn-endda.

if pnp-sw-found = 1.

  • it_str-pernr = p0002-pernr.

it_str-stat2 = p0000-stat2.

endif.

append it_str.

Regards,

Srini.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,885

Read some documentation like

- pdf : [Report Programming in HR|http://help.sap.com/printdocu/core/Print46c/en/data/pdf/PAXX/PYINT_PROGRAMM.pdf]

- html : [Report Programming in HR|http://help.sap.com/saphelp_47x200/helpdata/en/4f/d5275f575e11d189270000e8322f96/frameset.htm] or [Programming Utilities for the Logical Databases PNP and PAP|http://help.sap.com/saphelp_47x200/helpdata/en/60/d8bad2576311d189270000e8322f96/frameset.htm]

Regards,

Raymond

Read only

Former Member
0 Likes
1,885

Dear Swetha,

Just follow the same code document depicting a simple scenario of reading information posted by me on the other website. Follow

[Sample ABAP HR Report using LDB "PNP"|http://gauravpatwari.files.wordpress.com/2009/09/report-ymhcrobjonloan.pdf]

And go ahead with the one required by you. And to compare your requirement with this report just check with Infotype statement and the Infotypes you need.

<h5>Regards,

[Gaurav Patwari|http://gauravpatwari.wordpress.com]</h5>

Read only

0 Likes
1,885

This message was moderated.

Read only

Former Member
0 Likes
1,885

Hi Former Member,

TABLES : PERNR.

* Infpotypes Declartion

INFOTYPES : 0000,0001,0002,0105.

* Structure Declartion

TYPES : BEGIN OF TY_ITAB,

          PERNR TYPE P0001-PERNR ,

          WERKS TYPE P0001-WERKS ,

          CNAME TYPE P0002-CNAME ,

          STAT2 TYPE P0000-STAT2 ,

          USRID TYPE P0105-USRID ,

         END OF TY_ITAB.

DATA : ITAB TYPE TABLE OF TY_ITAB,

       WA TYPE TY_ITAB .

START-OF-SELECTION.

GET PERNR.

* macro definition

RP-PROVIDE-FROM-LAST P0001 SPACE PN-BEGDA PN-ENDDA.

RP-PROVIDE-FROM-LAST P0002 SPACE PN-BEGDA PN-ENDDA.

RP-PROVIDE-FROM-LAST P0105 SPACE PN-BEGDA PN-ENDDA.

RP-PROVIDE-FROM-LAST P0000 SPACE PN-BEGDA PN-ENDDA.

MOVE-CORRESPONDING P0001 TO WA.

MOVE-CORRESPONDING P0002 TO WA.

MOVE-CORRESPONDING P0105 TO WA.

MOVE-CORRESPONDING P0000 TO WA.

APPEND WA TO ITAB.

CLEAR WA.

END-OF-SELECTION.

SORT ITAB BY PERNR.

PERFORM TOP-OF-PAGE.

LOOP AT ITAB INTO WA.

   SHIFT WA-PERNR LEFT DELETING LEADING '0'.

   WRITE : /5 WA-PERNR,

            16 WA-WERKS,

            25 WA-CNAME,

            35 WA-STAT2,

            45 WA-USRID.

ENDLOOP.

*&---------------------------------------------------------------------*

*&      Form  TOP-OF-PAGE

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

FORM TOP-OF-PAGE .

   FORMAT COLOR COL_HEADING ON.

   WRITE : /5 'PERNR',

            16 'WERKS',

            25 'CNAME',

            35 'STAT2',

            45 'USRID'.

   FORMAT COLOR OFF.

ENDFORM.                    " TOP-OF-PAGE