Here is one way.

4m 38cm = 438cm

How many 161 cm are in 438 cm?

Two

So, what is left is 438 -2(161) = 116 cm

Let x = number of 23-cm rods

And y = number of 7-cm rods

So,

23x +7y = 116

x = (116 -7y)/23 -----**

By repetition, find the the integer value of y that will produce an integer x.

I found y = 10 to give x = 2

That means 10 rods of 7cm long

And 2 rods of 23 cm long

Therefore, the carpenter got 2 rods of 161cm long, 2 rods of 23cm long, and 10 rods of 7cm long. -------------answer.

Check:

2(161) +2(23) +10(7) =? 438

438 =? 438

Yes, so, OK.